AdManagerInterstitialAd

abstract class AdManagerInterstitialAd : InterstitialAd


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

サンプルコード:

public class MyActivity extends Activity {
    private AdManagerInterstitialAd adManagerInterstitialAd;
    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() {
               adManagerInterstitialAd = null;
               // Proceed to the next level.
               goToNextLevel();
            }
        };

        // Load a Google Ad Manager 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.
        AdManagerInterstitialAd.load(
            this,
            "myAdUnitId",
            new AdManagerAdRequest.Builder().build(),
            new AdManagerInterstitialAdLoadCallback() {
                @Override
                public void onAdLoaded(@NonNull AdManagerInterstitialAd ad) {
                    adManagerInterstitialAd = ad;
                    adManagerInterstitialAd.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 (adManagerInterstitialAd != null) {
                    adManagerInterstitialAd.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 AppEventListener?

この AdManagerInterstitialAdAppEventListener を返します。

java-static Unit
load(
    context: Context,
    adUnitId: String,
    adManagerAdRequest: AdManagerAdRequest,
    loadCallback: AdManagerInterstitialAdLoadCallback
)

AdManagerInterstitialAd を読み込みます。

abstract Unit

この AdManagerInterstitialAdAppEventListener を設定します。

継承される関数

継承元: com.google.android.gms.ads.interstitial.InterstitialAd
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)

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

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

AdManagerInterstitialAd

AdManagerInterstitialAd()

パブリック関数

getAppEventListener

abstract fun getAppEventListener(): AppEventListener?

この AdManagerInterstitialAdAppEventListener を返します。

load

java-static fun load(
    context: Context,
    adUnitId: String,
    adManagerAdRequest: AdManagerAdRequest,
    loadCallback: AdManagerInterstitialAdLoadCallback
): Unit

AdManagerInterstitialAd を読み込みます。

パラメータ
context: Context

コンテキスト。

adUnitId: String

広告ユニット ID。

adManagerAdRequest: AdManagerAdRequest

ターゲット設定情報を含む広告リクエスト。

loadCallback: AdManagerInterstitialAdLoadCallback

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

setAppEventListener

abstract fun setAppEventListener(appEventListener: AppEventListener?): Unit

この AdManagerInterstitialAdAppEventListener を設定します。