InterstitialAd

abstract class InterstitialAd

既知の直接サブクラス
AdManagerInterstitialAd

Google アド マネージャーのパブリッシャー向けに、ページ遷移、アプリの起動、ゲームのステージの読み込みなど、自然な画面切り替えポイントでフルページ型の広告を表示します。


ページ遷移、アプリの起動、ゲームのステージの読み込みなど、自然な画面切り替えポイントでフルページ型の広告を表示します。ボタンを押すと、インタースティシャル広告を閉じることができます。

サンプルコード:

public class MyActivity extends Activity {
    private InterstitialAd interstitialAd;
    private Button nextLevelButton;
    private TextView textView;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // Create a full screen content callback.
        FullScreenContentCallback fullScreenContentCallback = new FullScreenContentCallback() {
            @Override
            public void onAdDismissedFullScreenContent() {
               interstitialAd = null;
               // Proceed to the next level.
               goToNextLevel();
            }
        };

        // Load an interstitial ad. When a natural transition in the app occurs (such as a level
        // ending in a game), show the interstitial. In this simple example, the press of a
        // button is used instead.
        //
        // If the button is clicked before the interstitial is loaded, the user should proceed to
        // the next part of the app (in this case, the next level).
        //
        // If the interstitial is finished loading, the user will view the interstitial before
        // proceeding.
        InterstitialAd.load(
            this,
            "myAdUnitId",
            new AdRequest.Builder().build(),
            new InterstitialAdLoadCallback() {
                @Override
                public void onAdLoaded(@NonNull InterstitialAd ad) {
                    interstitialAd = ad;
                    interstitialAd.setFullScreenContentCallback(fullScreenContentCallback);
                }

                @Override
                public void onAdFailedToLoad(@NonNull LoadAdError adError) {
                    // Code to be executed when an ad request fails.
                }
            });

        // Create the button to go to the next level.
        nextLevelButton = new Button(this);
        nextLevelButton.setText("Next Level");
        nextLevelButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                // Show the interstitial if it is ready. Otherwise, proceed to the next level
                // without ever showing it.
                if (interstitialAd != null) {
                    interstitialAd.show(MyActivity.this);
                } else {
                    // Proceed to the next level.
                    goToNextLevel();
                }
            }
        });

        // Add the next level button to the layout.
        LinearLayout layout = new LinearLayout(this);
        layout.setOrientation(LinearLayout.VERTICAL);
        layout.addView(nextLevelButton);

        // Create a TextView to display the current level.
        textView = new TextView(this);
        textView.setText("Level 1");
        layout.addView(textView);

        setContentView(layout);
    }

    public void goToNextLevel() {
        // Show the next level, and disable the next level button since there are no more levels.
        nextLevelButton.setEnabled(false);
        textView.setText("Level 2");
    }
}

概要

パブリック コンストラクタ

パブリック関数

abstract String

広告ユニット ID を返します。

abstract FullScreenContentCallback?

この InterstitialAdFullScreenContentCallback を取得します。

abstract OnPaidEventListener?

この InterstitialAdOnPaidEventListener を取得します。

abstract Long

この InterstitialAd のプレースメント ID を返します。

abstract ResponseInfo

読み込まれた広告の ResponseInfo オブジェクトを返します。

java-static Boolean
isAdAvailable(context: Context, adUnitId: String)

この関数は非推奨になりました。

代わりに isAdAvailable を使用してください。

java-static Unit
load(
    context: Context,
    adUnitId: String,
    adRequest: AdRequest,
    loadCallback: InterstitialAdLoadCallback
)

InterstitialAd を読み込みます。

java-static InterstitialAd?
pollAd(context: Context, adUnitId: String)

この関数は非推奨になりました。

代わりに pollAd を使用してください。

abstract Unit
setFullScreenContentCallback(
    fullScreenContentCallback: FullScreenContentCallback?
)

広告が表示され、全画面コンテンツが閉じられたときに呼び出されるコールバックを登録します。

abstract Unit
setImmersiveMode(immersiveModeEnabled: Boolean)

このインタースティシャル オブジェクトを没入モードで表示するかどうかを制御するフラグを設定します。

abstract Unit

この広告で収益が発生したと推定されるときに呼び出されるコールバックを登録します。

abstract Unit
setPlacementId(placementId: Long)

インタースティシャル広告のプレースメント ID を設定します。

abstract Unit
show(activity: Activity)

インタースティシャル広告を表示します。

パブリック コンストラクタ

InterstitialAd

InterstitialAd()

パブリック関数

getAdUnitId

abstract fun getAdUnitId(): String

広告ユニット ID を返します。

getFullScreenContentCallback

abstract fun getFullScreenContentCallback(): FullScreenContentCallback?

この InterstitialAdFullScreenContentCallback を取得します。

getOnPaidEventListener

abstract fun getOnPaidEventListener(): OnPaidEventListener?

この InterstitialAdOnPaidEventListener を取得します。

getPlacementId

abstract fun getPlacementId(): Long

この InterstitialAd のプレースメント ID を返します。

getResponseInfo

abstract fun getResponseInfo(): ResponseInfo

読み込まれた広告の ResponseInfo オブジェクトを返します。広告が正常に読み込まれるまで null を返します。

isAdAvailable

java-static fun isAdAvailable(context: Context, adUnitId: String): Boolean

startPreload から読み込まれた利用可能なインタースティシャル広告がある場合、true を返します。

load

java-static fun load(
    context: Context,
    adUnitId: String,
    adRequest: AdRequest,
    loadCallback: InterstitialAdLoadCallback
): Unit

InterstitialAd を読み込みます。

パラメータ
context: Context

アクティビティまたはアプリのコンテキスト。

adUnitId: String

広告ユニット ID。

adRequest: AdRequest

ターゲティング情報を含む広告リクエスト。

loadCallback: InterstitialAdLoadCallback

インタースティシャル広告の読み込みが完了したときに呼び出されるコールバック。

pollAd

java-static fun pollAd(context: Context, adUnitId: String): InterstitialAd?

startPreload から読み込まれた次のインタースティシャル広告を取得します。広告が利用できない場合は null を取得します。

setFullScreenContentCallback

abstract fun setFullScreenContentCallback(
    fullScreenContentCallback: FullScreenContentCallback?
): Unit

広告が表示され、全画面コンテンツが閉じられたときに呼び出されるコールバックを登録します。

setImmersiveMode

abstract fun setImmersiveMode(immersiveModeEnabled: Boolean): Unit

このインタースティシャル オブジェクトをイマーシブ モードで表示するかどうかを制御するフラグを設定します。show の前にこのメソッドを呼び出します。show の間、このフラグがオンで没入モードがサポートされている場合、インタースティシャル広告に対して SYSTEM_UI_FLAG_IMMERSIVE_STICKY と SYSTEM_UI_FLAG_HIDE_NAVIGATION がオンになります。

setOnPaidEventListener

abstract fun setOnPaidEventListener(listener: OnPaidEventListener?): Unit

この広告で収益が発生したと推定されるときに呼び出されるコールバックを登録します。

setPlacementId

abstract fun setPlacementId(placementId: Long): Unit

インタースティシャル広告のプレースメント ID を設定します。

このプレースメント ID がレポートに含まれるようにするには、広告を表示する前にこのメソッドを呼び出します。

パラメータ
placementId: Long

構成されたプレースメント用に AdMob 管理画面から提供される長整数。

表示する

abstract fun show(activity: Activity): Unit

インタースティシャル広告を表示します。

パラメータ
activity: Activity

広告を表示する Activity コンテキスト。