AdManagerInterstitialAd

public abstract class AdManagerInterstitialAd extends InterstitialAd


Nutzern wird an natürlichen Übergangspunkten wie einem Seitenwechsel, dem Start einer App oder dem Laden eines Spiele-Levels eine ganze Seite mit Werbung angezeigt. Interstitial-Anzeigen haben eine Schaltfläche zum Schließen, mit der die Anzeige aus dem Sichtfeld des Nutzers entfernt wird.

Beispielcode:

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");
    }
}

Zusammenfassung

Öffentliche Konstruktoren

Öffentliche Methoden

abstract @Nullable AppEventListener

Gibt die AppEventListener für diese AdManagerInterstitialAd zurück.

static void
load(
    @NonNull Context context,
    @NonNull String adUnitId,
    @NonNull AdManagerAdRequest adManagerAdRequest,
    @NonNull AdManagerInterstitialAdLoadCallback loadCallback
)

Lädt ein AdManagerInterstitialAd.

abstract void

Legt eine AppEventListener für diese AdManagerInterstitialAd fest.

Geerbte Methoden

Aus com.google.android.gms.ads.interstitial.InterstitialAd
abstract @NonNull String

Gibt die Anzeigenblock-ID zurück.

abstract @Nullable FullScreenContentCallback

Ruft die FullScreenContentCallback für diese InterstitialAd ab.

abstract @Nullable OnPaidEventListener

Ruft die OnPaidEventListener für diese InterstitialAd ab.

abstract long

Gibt die Placement-ID für dieses InterstitialAd zurück.

abstract @NonNull ResponseInfo

Gibt das ResponseInfo-Objekt für die geladene Anzeige zurück.

static boolean
isAdAvailable(@NonNull Context context, @NonNull String adUnitId)

Diese Methode wurde eingestellt.

Verwenden Sie stattdessen isAdAvailable.

static void
load(
    @NonNull Context context,
    @NonNull String adUnitId,
    @NonNull AdRequest adRequest,
    @NonNull InterstitialAdLoadCallback loadCallback
)

Lädt ein InterstitialAd.

static @Nullable InterstitialAd
pollAd(@NonNull Context context, @NonNull String adUnitId)

Diese Methode wurde eingestellt.

Verwenden Sie stattdessen pollAd.

abstract void

Registriert einen Callback, der aufgerufen wird, wenn Anzeigen eingeblendet und Vollbildinhalte geschlossen werden.

abstract void
setImmersiveMode(boolean immersiveModeEnabled)

Legt ein Flag fest, mit dem gesteuert wird, ob dieses Interstitial-Objekt im immersiven Modus angezeigt wird.

abstract void

Registriert einen Callback, der aufgerufen wird, wenn mit dieser Anzeige voraussichtlich Einnahmen erzielt wurden.

abstract void
setPlacementId(long placementId)

Legt eine Placement-ID für die Interstitial-Anzeige fest.

abstract void
show(@NonNull Activity activity)

Die Interstitial-Anzeige wird eingeblendet.

Öffentliche Konstruktoren

AdManagerInterstitialAd

public AdManagerInterstitialAd()

Öffentliche Methoden

getAppEventListener

public abstract @Nullable AppEventListener getAppEventListener()

Gibt die AppEventListener für diese AdManagerInterstitialAd zurück.

load

public static void load(
    @NonNull Context context,
    @NonNull String adUnitId,
    @NonNull AdManagerAdRequest adManagerAdRequest,
    @NonNull AdManagerInterstitialAdLoadCallback loadCallback
)

Lädt ein AdManagerInterstitialAd.

Parameter
@NonNull Context context

Der Kontext.

@NonNull String adUnitId

Die Anzeigenblock-ID.

@NonNull AdManagerAdRequest adManagerAdRequest

Eine Anzeigenanfrage mit Targeting-Informationen.

@NonNull AdManagerInterstitialAdLoadCallback loadCallback

Ein Callback, der aufgerufen wird, wenn das Laden einer Google Ad Manager-Interstitial-Anzeige abgeschlossen ist.

setAppEventListener

public abstract void setAppEventListener(@Nullable AppEventListener appEventListener)

Legt eine AppEventListener für diese AdManagerInterstitialAd fest.