Advanced Settings - Vungle Android SDK


  1. Global Ad Configuration
  2. Single Ad Configuration
  3. Configuration Options
  4. Event Listener Interface
  5. Proguard

Please note: This article covers the advanced settings of the Vungle Android SDK. If you're just getting started with our Android SDK, you'll want to check out our Getting Started Guide for Android..

Global Ad Configuration

After calling init you can optionally get access to the global AdConfig object. This object allows you to set options that will be automatically applied to every ad you play.

import com.vungle.publisher.VunglePub;
import com.vungle.publisher.AdConfig;
import com.vungle.publisher.Orientation;

public class FirstActivity extends {


  public void onCreate(Bundle savedInstanceState) {


      vunglePub.init(this, app_id);

      // get a reference to the global AdConfig object
      final AdConfig globalAdConfig = vunglePub.getGlobalAdConfig();

      // set any configuration options you like. 
      // For a full description of available options, see the       
      // 'Configuration Options' section.


Single Ad Configuration

You can optionally customize each individual ad you play by providing an AdConfig object to playAd. If you set any options in the global ad configuration (above), those options will be overridden by the provided options.  Pass an override AdConfig with the following approach:

import com.vungle.publisher.VunglePub;
import com.vungle.publisher.AdConfig;

public class GameActivity extends {

  private void onLevelComplete() {
      // create a new AdConfig object
      final AdConfig overrideConfig = new AdConfig();

      // set any configuration options you like. 
      // For a full description of available options, see the       
      // 'Configuration Options' section.       overrideConfig.setIncentivized(true);

      // the overrideConfig object will only affect this ad play.

Configuration Options

The AdConfig Object

The override AdConfig has a collection of options that can be set for an individual ad play.  Available options are listed below: 

Method Default Description
setOrientation Orientation.matchVideo Orientation.autoRotateindicates that the ad will autorotate with the device orientation.Orientation.matchVideoindicates that that the ad will play in the best orientation for the video (usually landscape).
setSoundEnabled true Sets the starting sound state for the ad. If true, the audio respects device volume and sound settings. If false, video begins muted but user may modify.
setBackButtonImmediatelyEnabled false If true, allows the user to immediately exit an ad using the back button. If false, the user cannot use the back button to exit the ad until the on-screen close button is shown.
setImmersiveMode false Enables or disables immersive mode on KitKat+ devices
setIncentivized false Sets the incentivized mode - you must set this to true if you're using server-to-server callbacks for your rewarded ads. If true, user will be prompted with a confirmation dialog when attempting to skip the ad. If false, no confirmation is shown. Further instructions for setting up incentivized ads are here.
setIncentivizedUserId none Sets the unique user id to be passed to your application to verify that this user should rewarded for watching an incentivized ad. N/A if ad is not incentivized.
setIncentivizedCancelDialogTitle "Close video?" Sets the title of the confirmation dialog when skipping an incentivized ad. N/A if ad is not incentivized.
setIncentivizedCancelDialogBodyText "Closing this video early will prevent you from earning your reward. Are you sure?" Sets the body of the confirmation dialog when skipping an incentivized ad. N/A if ad is not incentivized.
setIncentivizedCancelDialogCloseButtonText "Close video" Sets the 'cancel button' text of the confirmation dialog when skipping an incentivized ad. N/A if ad is not incentivized.
setIncentivizedCancelDialogKeepWatchingButtonText "Keep watching" Sets the 'keep watching button' text of the confirmation dialog when skipping an incentivized ad. N/A if ad is not incentivized.
setTransitionAnimationEnabled false Enables or disables standard fragment transition animation

Showing the Close Button

To control whether a user has the option to close out of an ad, use the forced view options in your app's advanced settings on the Vungle Dashboard.

The EventListener Interface

The Publisher SDK raises several events that you can handle programmatically by implementing com.vungle.publisher.EventListener classes and registering/removing them using:

VunglePub.setEventListeners(eventListener1, eventListener2, ...)

Remember to remove the eventListener when you don't need to use it anymore to prevent memory leak.

Available methods to manipulate the EventListener are listed below:

Method Description
 addEventListeners() Clears registered EventListeners and then adds the input eventListeners. 
 clearEventListeners() Clears EventListeners
 removeEventListeners() Removes the input EventListeners.

UI Thread Note

The callbacks are executed on a background thread, so any UI interaction/updates resulting from an event callback need to be passed to the main UI thread before executing. Two common ways to run your code on the UI thread are:

import com.vungle.publisher.EventListener;

public class FirstActivity extends {

  private final EventListener vungleListener = new EventListener()

    public void onAdStart() {
        // Called before playing an ad

    public void onAdEnd(boolean wasSuccessfulView, boolean wasCallToActionClicked) {
        // Called when the user leaves the ad and control is returned to your application        
        // if wasSuccessfulView is true, the user watched the ad and should be rewarded        
        // (if this was a rewarded ad).
        // if wasCallToActionClicked is true, the user clicked the call to action
        // button in the ad.

    public void onAdPlayableChanged(boolean isAdPlayable) {
        // Called when the playability state changes. if isAdPlayable is true, you can now        
        // play an ad.
        // If false, you cannot yet play an ad.

    public void onAdUnavailable(String reason) {
        // Called when VunglePub.playAd() was called, but no ad was available to play


  public void onCreate(Bundle savedInstanceState) {

      vunglePub.init(this, app_id);


@Override public void onDestroy() { ... vunglePub.clearEventListeners(); };


If you are using Proguard, please ensure the following lines are in your Proguard config file:

-dontwarn com.vungle.**
-dontnote com.vungle.**
-keep class com.vungle.** { *; }
-keep class javax.inject.*
# ignore eventbus warnings
-dontwarn de.greenrobot.event.util.**
# ignore rx warnings
-dontwarn rx.internal.util.unsafe.**
# keep some important rx stuff -
-keepclassmembers class rx.internal.util.unsafe.*ArrayQueue*Field* {
long producerIndex;
long consumerIndex;
-keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueProducerNodeRef {
rx.internal.util.atomic.LinkedQueueNode producerNode;
-keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueConsumerNodeRef {
rx.internal.util.atomic.LinkedQueueNode consumerNode;
-keep class rx.schedulers.Schedulers { public static <methods>; }
-keep class rx.schedulers.ImmediateScheduler { public <methods>; }
-keep class rx.schedulers.TestScheduler { public <methods>; }
-keep class rx.schedulers.Schedulers { public static ** test(); }

Have more questions? Submit a request