Getting started with the Android SDK

This article is to help setting an Android project using PhenixRTS Android SDK alongside our API documentation (found here).

Prerequisites:

Android studio and development environment. Installation instructions can be found here.

Instructions

To set up and build a project using our Android SDK, follow the instructions in this section.

  1. Open android studio and create a new project.

  2. Add the following dependency to app/build.gradle:

    implementation "com.phenixrts.android:phenix-sdk-android:2021.0.15"

     

    PhenixRTS SDK dependency in app/build.gradle

    If you are using a different version of the Phenix Android SDK, use that version number in place of 2021.0.15.

  3. Add maven credentials and url to the project’s settings.gradle file (replace values with your own).

    maven { credentials { username "YOUR_GIT_USERNAME" password "YOUR_GIT_KEY" } url "https://maven.pkg.github.com/PhenixRTS/AndroidSDK" }



    Git credentials in the project’s settings.gradle

     

  4. Once you have added the dependency and git settings, be sure to sync the gradle settings. The project will not compile without synchronizing these settings.

  5. Add a surface view to activity_main.xml as shown below:

    <SurfaceView android:id="@+id/surface" android:layout_width="match_parent" android:layout_height="match_parent" android:keepScreenOn="true" tools:layout_editor_absoluteX="52dp" tools:layout_editor_absoluteY="0dp"/>

     

  6. Add the following code to your MainActivity.kt, replacing the token and channel alias with actual values as indicated.

     

  7. Run project to view stream (either on a device or an emulator).

Troubleshooting

  1. Be sure to have a stream published that corresponds to the alias and token that you used in the code snippet above.

  2. Double check that you have setup your GitHub to use an access token.

  3. Confirm that you have android:keepScreenOn="true" on your SurfaceView object in the main_activity.xml.

More information

More information about the Phenix Android SDK and GitHub can be found at the following links.

©2020-2021 Phenix Real Time Solutions, Inc.