Displaying a Player - Android

Initialization

  1. Initialize the SDK. Call SDK initialization in Application.onCreate():

Your application may not contain a custom implementation of the Application class. In such a case you should create one.

Kotlin

Inside Application class:

initializeAdPlayer()

or anywhere else (not recommended):

AdPlayer.initialize(context)

Java

AdPlayer.initialize(context);

Calling any of the AdPlayer APIs before initialization will result in errors!

Before this method is called, the SDK will not perform any operations and will not use any resources (memory, cpu, network etc.).

  • Initialization allows to provide an additional optional parameter for user identification. Providing this parameter will allow us to identify a specific user within our system for debugging or sharing of information.

Kotlin

Inside Application class:

or anywhere else (not recommended):

Java

2. Initialize the player tags. To be called right after initialize in Application.onCreate().

In case the tags belong to more than one publisher, this method must be called once per publisher.

Kotlin

Inside Application class:

or anywhere else (not recommended):

Java

Preparing the UI placement(s) of your player tag(s)

Presenting using static XML layout

Add a AdPlayerPlacementView XML element to your layout in the position where you want the player to be displayed. Assign the ID of the player tag that should be presented in this placement by adding the following configuration to the element: app:player_tag=<your tag ID>.

Once the player tag is initialized and the AdPlayerPlacementView is visible on the screen, the player will be loaded and the content of the assigned player tag will be presented.

Present using dynamically created layout

If you wish to programmatically create the AdPlayerPlacementView or simply reuse the same XML layout to present different players, then AdPlayerPlacementView.attachPlayerTag(tagId) must be called to associate a player tag to the placement.

Kotlin

Java