com.applovin.adview.AppLovinInterstitialAd Java Examples

The following examples show how to use com.applovin.adview.AppLovinInterstitialAd. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AppLovinRtbInterstitialRenderer.java    From googleads-mobile-android-mediation with Apache License 2.0 6 votes vote down vote up
public void loadAd() {
  Context context = adConfiguration.getContext();
  if (!(context instanceof Activity)) {
    String adapterError =
        createAdapterError(
            ERROR_CONTEXT_NOT_ACTIVITY, "AppLovin requires an Activity context to load ads.");
    Log.e(TAG, "Failed to load interstitial ad from AppLovin: " + adapterError);
    callback.onFailure(adapterError);
    return;
  }

  // Create interstitial object
  interstitialAd = AppLovinInterstitialAd.create(sdk, context);
  interstitialAd.setAdDisplayListener(this);
  interstitialAd.setAdClickListener(this);
  interstitialAd.setAdVideoPlaybackListener(this);

  // Load ad!
  sdk.getAdService().loadNextAdForAdToken(adConfiguration.getBidResponse(), this);
}
 
Example #2
Source File: AppLovinCustomEventInterstitial.java    From SDK-Network-Adapters with MIT License 6 votes vote down vote up
@Override
public void showInterstitial()
{
    final AppLovinAd preloadedAd = dequeueAd( zoneId );
    if ( preloadedAd != null )
    {
        final AppLovinInterstitialAdDialog interstitialAd = AppLovinInterstitialAd.create( sdk, context );
        interstitialAd.setAdDisplayListener( this );
        interstitialAd.setAdClickListener( this );
        interstitialAd.setAdVideoPlaybackListener( this );
        interstitialAd.showAndRender( preloadedAd );
    }
    else
    {
        log( ERROR, "Failed to show an AppLovin interstitial before one was loaded" );
        listener.onInterstitialFailed( MoPubErrorCode.NETWORK_INVALID_STATE );
    }
}
 
Example #3
Source File: AppLovinCustomEventInterstitial.java    From SDK-Network-Adapters with MIT License 6 votes vote down vote up
@Override
public void showInterstitial()
{
    final AppLovinAd preloadedAd = dequeueAd( zoneId );
    if ( preloadedAd != null )
    {
        final AppLovinSdk sdk = AppLovinSdk.getInstance( context );

        final AppLovinInterstitialAdDialog interstitialAd = AppLovinInterstitialAd.create( sdk, context );
        interstitialAd.setAdDisplayListener( this );
        interstitialAd.setAdClickListener( this );
        interstitialAd.setAdVideoPlaybackListener( this );
        interstitialAd.showAndRender( preloadedAd );
    }
    else
    {
        log( ERROR, "Failed to show an AppLovin interstitial before one was loaded" );
        listener.onAdFailedToLoad( AdRequest.ERROR_CODE_INTERNAL_ERROR );
    }
}
 
Example #4
Source File: InterstitialBasicIntegrationActivity.java    From Android-SDK-Demo with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState)
{
    super.onCreate( savedInstanceState );
    setContentView( R.layout.activity_interstitial_basic_integration );

    adStatusTextView = (TextView) findViewById( R.id.status_label );

    interstitialAd = AppLovinInterstitialAd.create( AppLovinSdk.getInstance( this ), this );

    showButton = (Button) findViewById( R.id.showButton );
    showButton.setOnClickListener( new View.OnClickListener()
    {
        @Override
        public void onClick(View v)
        {
            showButton.setEnabled( false );

            log( "Showing..." );

            //
            // Optional: Set ad load, ad display, ad click, and ad video playback callback listeners
            //
            interstitialAd.setAdLoadListener( InterstitialBasicIntegrationActivity.this );
            interstitialAd.setAdDisplayListener( InterstitialBasicIntegrationActivity.this );
            interstitialAd.setAdClickListener( InterstitialBasicIntegrationActivity.this );
            interstitialAd.setAdVideoPlaybackListener( InterstitialBasicIntegrationActivity.this ); // This will only ever be used if you have video ads enabled.

            interstitialAd.show();
        }
    } );
}
 
Example #5
Source File: ApplovinAdapter.java    From googleads-mobile-android-mediation with Apache License 2.0 5 votes vote down vote up
@Override
public void showInterstitial() {
  synchronized (INTERSTITIAL_AD_QUEUES_LOCK) {
    // Update mute state.
    mSdk.getSettings().setMuted(AppLovinUtils.shouldMuteAudio(mNetworkExtras));

    final Queue<AppLovinAd> queue = INTERSTITIAL_AD_QUEUES.get(mZoneId);
    final AppLovinAd dequeuedAd = (queue != null) ? queue.poll() : null;

    final AppLovinInterstitialAdDialog interstitialAd =
        AppLovinInterstitialAd.create(mSdk, mContext);

    final AppLovinInterstitialAdListener listener =
        new AppLovinInterstitialAdListener(this, mMediationInterstitialListener);
    interstitialAd.setAdDisplayListener(listener);
    interstitialAd.setAdClickListener(listener);
    interstitialAd.setAdVideoPlaybackListener(listener);

    if (dequeuedAd != null) {
      log(DEBUG, "Showing interstitial for zone: " + mZoneId);
      interstitialAd.showAndRender(dequeuedAd);
    } else {
      log(DEBUG, "Attempting to show interstitial before one was loaded.");

      // Check if we have a default zone interstitial available.
      if (TextUtils.isEmpty(mZoneId) && interstitialAd.isAdReadyToDisplay()) {
        log(DEBUG, "Showing interstitial preloaded by SDK.");
        interstitialAd.show();
      }
      // TODO: Show ad for zone identifier if exists
      else {
        mMediationInterstitialListener.onAdOpened(this);
        mMediationInterstitialListener.onAdClosed(this);
      }
    }
  }
}