コンテンツにスキップ

インタースティシャル広告(Interstitial ads)

インタースティシャル広告の読み込み

インタースティシャル広告をロードするには、広告ユニットに対応するMaxInterstitialAdオブジェクトをインスタンス化してから、そのオブジェクトのloadAd()メソッドを呼び出します。 広告の準備が完了した際に通知されるように、MaxAdListenerを実装します。これにより、他の広告関連イベントも通知されます。

public class ExampleActivity extends Activity
implements MaxAdListener
{
private MaxInterstitialAd interstitialAd;
private int retryAttempt;
void createInterstitialAd()
{
interstitialAd = new MaxInterstitialAd( "«ad-unit-ID»", getApplicationContext() );
interstitialAd.setListener( this );
// Load the first ad
interstitialAd.loadAd();
}
// MAX Ad Listener
@Override
public void onAdLoaded(final MaxAd maxAd)
{
// Interstitial ad is ready to be shown. interstitialAd.isReady() will now return 'true'
// Reset retry attempt
retryAttempt = 0;
}
@Override
public void onAdLoadFailed(final String adUnitId, final MaxError error)
{
// Interstitial ad failed to load
// AppLovin recommends that you retry with exponentially higher delays up to a maximum delay (in this case 64 seconds)
retryAttempt++;
long delayMillis = TimeUnit.SECONDS.toMillis( (long) Math.pow( 2, Math.min( 6, retryAttempt ) ) );
new Handler().postDelayed( new Runnable()
{
@Override
public void run()
{
interstitialAd.loadAd();
}
}, delayMillis );
}
@Override
public void onAdDisplayFailed(final MaxAd maxAd, final MaxError error)
{
// Interstitial ad failed to display. AppLovin recommends that you load the next ad.
interstitialAd.loadAd();
}
@Override
public void onAdDisplayed(final MaxAd maxAd) {}
@Override
public void onAdClicked(final MaxAd maxAd) {}
@Override
public void onAdHidden(final MaxAd maxAd)
{
// Interstitial ad is hidden. Pre-load the next ad
interstitialAd.loadAd();
}
}

インタースティシャル広告の表示

インタースティシャル広告を表示するには、作成したMaxInterstitialAdオブジェクトでshowAd( this )を呼び出します。

if ( interstitialAd.isReady() )
{
// `this` is the activity that will be used to show the ad
interstitialAd.showAd( this );
}

ロック画面広告

AppLovin MAX SDKは、ロック画面にインタースティシャル広告を表示できるAPIを提供します。この統合のユースケースには、通常ロック画面に表示されるオーディオアプリが含まれます。

ロック画面広告の読み込み

前述のプロセスを利用して、通常のインタースティシャル広告のロードと類似の方法で、インタースティシャル広告をロック画面に表示します。 ただし、MaxInterstitialAdに追加のパラメーターを設定する必要があり、渡すActivityLifecycleOwnerインターフェイスを実装する必要があります。

import androidx.lifecycle.LifecycleOwner;
public class ExampleActivity extends Activity
implements MaxAdListener, LifecycleOwner
{
private FrameLayout adContainerView;
private MaxInterstitialAd interstitialAd;
private int retryAttempt;
void createInterstitialAd()
{
interstitialAd = new MaxInterstitialAd( "«ad-unit-ID»", getApplicationContext() );
interstitialAd.setExtraParameter( "container_view_ads", "true" );
interstitialAd.setListener( this );
// Load the first ad
interstitialAd.loadAd();
}
// MAX Ad Listener
}

ロック画面広告の表示

ロック画面にインタースティシャル広告を表示するには、広告の ViewGroupshowAd(…)を呼び出します。

if ( interstitialAd.isReady() )
{
// `this` is the activity that will be used to show the ad
interstitialAd.showAd( adContainerView, getLifecycle(), this );
}

仲介ネットワークのサポート

この機能をサポートするネットワークは、AppLovin BiddingとAppLovin Exchangeです。

アダプターへのカスタム・サポートの追加

カスタムアダプターまたは当社のオープンソースアダプターにサポートを追加するには、以下のshowInterstitialAd(…)メソッドを上書きしてください。

@Override
public void showInterstitialAd(final MaxAdapterResponseParameters parameters,
final ViewGroup containerView,
final Lifecycle lifecycle,
final Activity activity,
final MaxInterstitialAdapterListener listener)
{
}