Android SDK FAQ

How to play Audio Ads along with Dialogue Ads?

If you are going to be playing Audio Ads, along with Voice-Activated Ads, you will need to use the following code
Instead of

How to preload ads?

In the case of preloading, it is necessary to call the method adman.sendCanShow() at the time of possible launch of advertising, even in cases, when advertising wasn't actually loaded.
To preload an ad, please use the following
  • In case of the preload completed correctly, onAdmanEvent would be raised with AdmanEvent.Type.READY
  • If there is no advertisement AdmanEvent.Type.NONE will be raised.
  • In case of the preload error AdmanEvent.Type.ERROR will be raised.
When the AdmanEvent.Type.READY is raised, then playback can be started. Before the playback you need to call adman.sendCanShow() method. Then you can start playback using following:;
The AdmanEvent.Type.PLAYING will be raised once the playback begins. The AdmanEvent.Type.COMPLETED will be raised after the end of ad playback.

How to change screen orientation?

If an application supports the screen orientation change, the following code should be used to update the advertisement:
public void onConfigurationChanged(Configuration newConfig) {
((IAdmanView) adman.getModule(IAdmanView.ID)).rebuild();

How to run multiple instances of Adman?

Please use the following code in order to run multiple instances of Adman for different regions:
adman = new Adman(context,
new AdmanRequest[]{
new AdmanRequest.Builder().setRegion(Region.EUROPE).setSiteId(777).build(), new AdmanRequest.Builder().setRegion(Region.GLOBAL).setSiteId(777).build(),

How to specify slot while requesting an ad?

In order to set the slot, please use the following code:
AdmanRequest.Builder parameters = new AdmanRequest.Builder().setSlot(Slot.NAME);
In order to update the 'Slot' parameter, please use the following call before calling adman.preload()
Possible values for NAME:
Value Name
Will play only ads that should be played before the content or ads without specific slot.
Will play only ads that should be played in the middle of the content or ads without specific slot.
Will play only ads that should be played after the content or ads without specific slot.

How to customize the look of Ad View?

BaseAdmanView module is used to send the events from Adman (ad playback module) to visual elements of the SDK.
BaseAdmanView consists of the set of elements which are all described in AdmanViewType:
Element Name
Element Description
layout with all the elements which are used to show the Audio Ad
banner view
play button in the view
pause button in the view
the timer
layout for Dialogue Ads
microphone indication
indication of voice recognition
In order to use your custom layout with custom elements, you need to inherit BaseAdmanView class. Then do the following:
public IAdmanViewBundleFactory factory() {
return this.factory;
You can find the usage example HERE
The factory method delivers the set of the elements (mentioned above) with the help of IAdmanViewBundleFactory interface.
All the visual elements are grouped according to the type of an ad (Audio or Dialogue) and to screen orientation. Please see the AdmanViewBindFactory for reference HERE
Next step is to send the instance of this class to Adman. Please see the example on how you can do this:
adman.bindModule(new DemoVoiceAdmanView(this));
Please do not forget that you should use the real module and class names from your actual project.
You can find the full example of the modified ad views HERE and HERE

How to send data to MediaSessions Framework?

If you need to send the ad data in order to use it in MediaSessions Framework, then you just need to call the following method:
This method must be called when the ad start playing, during the PLAYING state of PlayerEvent.
This method will return the following values: METADATA_KEY_MEDIA_ID, METADATA_KEY_TITLE, METADATA_KEY_ALBUM_ART_URI, CLICK_THROUGH, then these values can be used with MediaSessions Framework.

How to use variables for targeting in the SDK?

You need to use the code below in order to send variables:
import com.instreamatic.adman.variable.AdmanVariable;
IAdman adman = new Adman(...);
Map<String, String> variables = new HashMap<>();
variables.put("variable1", "value1");
variables.put("variable2", "value2");
adman.bindModule(new AdmanVariable(variables));
If you need to change the value of the variable, you need to update it with the below method before requesting the new ad.
adman.updateRequest(request_builder, true);
Consent String can be sent by adding String consentString = ...; to the request. Please see the example below:
String consentString = ...;
AdmanRequest request = new AdmanRequest.Builder()
//creating Ad object
adman = new Adman(this, request);
//For CCPA consent string please use the following:

How to send a custom user id?

Custom user id can be used for targeting in cases when an app user restricted usage of advertising id or idfa. It can be any kind of in-app id, so tailored ads will work inside your app.
The max length for this string is 32 and it's not allowed to use special characters and spaces.
AdmanRequest request = new AdmanRequest.Builder()
//creating Ad object
adman = new Adman(this, request);