Project Setup
- Open Android Studio and Create a New Project
- Fill in the appropriate project options and select Tabbed Activity as the template
- In the Options dialog, set the Activity Name to
StreamingActivity
and select Action Bar Tabs for the Navigation Style field - After the project has finished being generated, Unzip the Red5 Pro Android Streaming SDK
- Click on Android tab in upper left and select Project
- Move the JAR files from the libs folder of the distribution into the libs directory for your Android project
- Move the jniLibs folder included in the distribution to the src/main (or equivalent dependending on your Gradle setup) for your Android project
- 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" />
-
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; } }