To test this feature and view the example code, please see the Android SDK 5 Example Code Quick Start guide.

The Android OS allows applications to be notified whenever an output is connected to the device (e.g. Chromecast, MHL, HDMI, etc.). This is useful, for example, for some DRM systems to make decisions whether protected streams should be allowed to play. The CONNECT Player SDK uses this ability and provides a detection class, OTVDeviceConnectDetector, which the application can use. The application needs to instantiate this class and then assign it a listener, OTVDeviceConnectDetector.OTVDeviceConnectListener. The listener would then get onDeviceConnected(int xDeviceType) and onDeviceDisconnected(int xDeviceType) notification callbacks whenever an output is connected or disconnected respectively.

Example code

The Java source code in the output-control example code contains the DeviceConnectionNotifier class, simplifying setting up an output-control listener. The application instantiates this class when the activity is created and then enables the notifier.

protected void onCreate(Bundle savedInstanceState) {

    // The OTVSDK.load() method must be called before SDK can be used
    // You may wish to do this in an application class

    DeviceConnectionNotifier deviceConnectionNotifier = new DeviceConnectionNotifier(getApplicationContext());



The DeviceConnectionNotifier instantiates the OTVDeviceConnectDetector class and register a listener with it. The implementation of the listener displays Toasts whenever an event is received for either connection or disconnection of an output device. More functionality may be added to handle events depending on the nature of the event and the application needs.