Android Second Screen Client Quickstart

The Red5 Pro Second Screen Android SDK provides the ability to add Second Screen experiences to your Native Applications on Androir devices.

Download the Red5 Pro Android Second Screen SDKs Download the latest Second Screen Native Client SDK for Android

Included in the Red5 Pro Android Second Screen SDK is an example project with Android Studio support.


The Red5 Pro Android Second Screen SDK has a minimum support for Android 4.1 / API Level: 16.

Basic Setup

Once you have downloaded the Android SDK and the Red5 Pro iOS Second Screen SDK, open Xcode and start a create a new project or open an existing project you want to add Second Screen to. To add the Red5 Pro Second Screen libraries to your project:

Adding the Framework and Dependencies

  • Add the sdk/red5pro-secondscreen.aar module to your project
  • Add the support/jackson-core-2.2.3.jar support library to the libs folder of your project

Defining the Manifest Requirements

  • Add required permissions to AndroidManifest.xml:
    • The minimum permissions needed are INTERNET, ACCESS_NETWORK_STATE, ACCESS_WIFI_STATE, and READ_PHONE_STATE.
<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" />
  • If you plan to use vibration, the VIBRATE permission is also required.
<uses-permission android:name="android.permission.VIBRATE" />
  • Add the Second Screen service to AndroidManifest.xml:
<service android:name="com.infrared5.secondscreen.client.SecondScreenService"


The Second Screen Client must be configured before it is used. This is most simply done in the the Application's onCreate method. The registry server hostname and red5 application name are required, and other things can be optionally configured.

import com.infrared5.secondscreen.client.SecondScreen;
import com.infrared5.secondscreen.client.SecondScreenConfig;


public class MyApplication extends Application {
  public void onCreate() {

    SecondScreenConfig config = SecondScreenConfig.createDefault();

Binding to the service

The SecondScreenService does the core of the work of the second screen client. While an activity is bound to it, it will maintain a connection to the registry server and to any host that it is connected to. One binds to it by creating a subclass of the SecondScreenConnection class, and overriding the onBound and onUnbound methods. One should add any needed listeners in onBound and remove them in onUnbound. The simplest way to bind the connection is to call bind in the activity's onStart method, and call unbind in onStop.

// in sample activity
private final SecondScreenConnection mConnection = new SecondScreenConnection() {
    protected void onBound(SecondScreenService service) {
        // add listeners here

    protected void onUnbound(SecondScreenService service) {
        // remove listeners here

protected void onStart() {

protected void onStop() {

Connecting to a Host

Once it is bound, the service will begin listening for available hosts. One can register a HostListListener to be notified when the list of available hosts changes. Once you have a host that you want to connect to, call the call the connectToHost method.

SecondScreenService service = mConnection.getService();

To be notified when a host connects, register a ConnectListener with the service. It will be notified when a Host connects, or fails to connect with an error. A DisconnectListener is notified when the host disconnects.

Binding to second screen view

The SecondScreenView is responsible for loading and displaying the controls specified by the host. A second screen view can be created in the layout xml, or programmatically through code. The xml allows one to specify the layout to use when loading the controls. If no loading layout is specified, none will be used.


Once connected to a host, one can bind the view to the host session very easily:

SecondScreenView view = (SecondScreenView)findViewById(;

Rpc Handling

Once connected to a host, one can also send rpc calls to and from the host. To send rpc calls to the host, simply call the sendRpc method on the HostSession. It takes the name of the method, and any combination of string, numeric, or boolean arguments.

session.sendRpc("testing", 1, 2, 3);
session.sendRpc("enableRobot", true);
session.sendRpc("seenAdjective", "spooky");

One handles rpc calls from the host by specifying a RpcTarget. All rpc methods on the target must be public and have the @RpcMethod annotation.

class TestRpcHandler implements RpcTarget {
    public void foo() {
        // use your imagination

    public void testing(int a, int b, float c) {
        // use your imagination

    public void enableRobot(boolean enabled) {
        // use your imagination

    public void seenAdjective(String adjective) {
        // use your imagination

// later on...
session.setRpcHandler(new TestRpcHandler());

API Documentation

For more in-depth documentation about the structure of the Android Second Screen Native Client SDK, please visit: Android Second Screen API Documentation

Native Client Example

We have created and shared an example of an Android Native Client project that incorporates the Live Streaming and Second Screen SDKS.

Download the Android Red Pro Native Client Example Download the latest Native Client Example for Android