/

Project Setup


  1. Open Android Studio and Create a New Project
  2. Fill in the appropriate project options and select Tabbed Activity as the template
  3. In the Options dialog, set the Activity Name to StreamingActivity and select Action Bar Tabs for the Navigation Style field
  4. After the project has finished being generated, Unzip the Red5 Pro Android Streaming SDK
  5. Click on Android tab in upper left and select Project
    Select the Android Project
  6. Move the JAR files from the libs folder of the distribution into the libs directory for your Android project
    Select the Android Project
  7. Move the jniLibs folder included in the distribution to the src/main (or equivalent dependending on your Gradle setup) for your Android project
    Select the Android Project
  8. Open the AndroidManifest.xml and add the following permissions
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.CAPTURE_AUDIO_OUTPUT" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
  1. A FragmentPagerAdapter was autogenerated upon project creation and added to the StreamingActivity as SectionsPagerAdapter. We will modify this implementation in order to support switching between Publisher and Subscriber activities for our streaming application example. Open StreamingActivity and modify SectionsPagerAdapter as such for now:

    public class SectionsPagerAdapter extends FragmentPagerAdapter {
    
      public SectionsPagerAdapter(FragmentManager fm) {
        super(fm);
      }
    
      @Override
      public Fragment getItem(int position) {
        // getItem is called to instantiate the fragment for the given page.
        // Return a PlaceholderFragment (defined as a static inner class below).
        return PlaceholderFragment.newInstance(position + 1);
      }
    
      @Override
      public int getCount() {
        return 2;
      }
    
      @Override
      public CharSequence getPageTitle(int position) {
        Locale l = Locale.getDefault();
        switch (position) {
          case 0:
            return "Publish";
          case 1:
            return "Subscribe";
        }
        return null;
      }
    }