Skip to main content
Skip table of contents

Android SDK 4 Example Code Quick Start

The following process describes how to quickly build the OpenTV player app for Android using the example code.

Prerequisites

The following development tools need to be installed; the number in square brackets is the earliest supported version of the software and verified by Nagra.

NAGRA supplies the following files as part of your release:

  • The SDK package
  • The Operator Vault file (opvault.json) - specific for each customer

Overview of the example code

The example code archive (zip) is a collection of code snippets, each demonstrating one aspect of the SDK capabilities. The code is arranged so that each example can be built and run on an Android device. Each example code folder in the zip file contains an independent Android application project. The following examples are provided:

Once you understand how the code works, you can use it in your own applications.

Specific streams and head-end addresses used to demonstrate the various functionalities may not be accessible in your own environment.

Building each example code

Example project structure

Each example is in a separate folder, containing an entire Android project, including:

  • .\build.gradle: A Gradle script that manages the dependencies and the build process
  • .\libs\: A folder to contain Java libraries
  • .\src\main\AndroidManifest.xml: A File configuring the application and the permissions it requires
  • .\src\main\java\: The source code of the example
  • .\src\main\res\: The resources folder for the application

Additional files to make the application build and run

Each of the example projects has a dependency on one or more Java libraries (.JAR files) and other files.

All projects need the SDK library. Copy one (and only one) of the SDK libraries to the .\libs\ folder of the project; copy either the opy-sdk-android-4.24.x-integration.jar (recommended for debugging) or the opy-sdk-android-4.24.x-production.jar library provided in the SDK package.

For PRM-protected content (the prm-encrypted-playback example), more files need to be copied:

  • The PAK libraries opy-sdk-android-4.24.x-cpakjava.securestorageagent-3.11.2.0.jar and opy-sdk-android-4.24.x-cpak-3.11.2.0.jar need to be copied to the .\libs\ folder of the project.
  • Copy your Operator Vault (opvault.json) to the .\src\main\res\raw\ folder. A version of this file matching the stream and head-end in the example code will already exist there but will need to be replaced if you want to change the settings to a stream hosted at your premises.

Building and executing an example with Android Studio

Once the additional files are copied:

  1. Open Android Studio and connect an Android device (ensuring USB debugging is enabled).
  2. Choose Open an existing Android Studio project and select the top directory of the example you want to build.
  3. Android initiates opening the project and updates the dependencies configured in the build.gradle file.
  4. At the configuration box, select the application configuration, click the green Play arrow button next to it and select the target Android device.
  5. The application builds, installs on your device and starts executing.

Building and executing an example from the command line

Once the additional files are copied:

  1. Open the Command/Terminal window and connect an Android device (ensuring USB debugging is enabled).
  2. Navigate to the top directory of the example you want to build.
  3. Execute the gradle wrapper command below to build the example code.

    BASH
    gradlew "assembleDebug"
  4. This will build a debug apk executable package and place it in the .\build\outputs\apk\debug\ folder. Install this package on your device using:

    BASH
    adb install -r ./build/outputs/apk/debug/<example-name>-debug.apk
  5. There should now be an icon in your application list to execute the example application.
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.