AdManagerInterstitialAd

abstract class AdManagerInterstitialAd : InterstitialAd


Il s'agit d'annonces occupant tout l'écran et diffusées à des points de transition naturels, par exemple à un changement de page, au lancement d'une application ou au téléchargement d'un niveau de jeu pour les éditeurs Google Ad Manager. Elles comportent un bouton permettant à l'utilisateur de les fermer.

Exemple de code :

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

Résumé

Constructeurs publics

Fonctions publiques

abstract AppEventListener?

Renvoie le AppEventListener pour ce AdManagerInterstitialAd.

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

Charge un AdManagerInterstitialAd.

abstract Unit

Définit un AppEventListener pour ce AdManagerInterstitialAd.

Fonctions héritées

From com.google.android.gms.ads.interstitial.InterstitialAd
abstract String

Renvoie l'ID du bloc d'annonces.

abstract FullScreenContentCallback?

Récupère le FullScreenContentCallback pour ce InterstitialAd.

abstract OnPaidEventListener?

Récupère le OnPaidEventListener pour ce InterstitialAd.

abstract Long

Renvoie l'ID de l'emplacement pour cet objet InterstitialAd.

abstract ResponseInfo

Renvoie l'objet ResponseInfo pour l'annonce chargée.

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

Cette fonction est obsolète.

Utilisez isAdAvailable à la place.

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

Charge un InterstitialAd.

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

Cette fonction est obsolète.

Utilisez pollAd à la place.

abstract Unit
setFullScreenContentCallback(
    fullScreenContentCallback: FullScreenContentCallback?
)

Enregistre un rappel à invoquer lorsque des annonces affichent et ferment du contenu en plein écran.

abstract Unit
setImmersiveMode(immersiveModeEnabled: Boolean)

Définit un indicateur qui détermine si cet objet interstitiel sera affiché en mode immersif.

abstract Unit

Enregistre un rappel à invoquer lorsque cette annonce est estimée avoir généré des revenus.

abstract Unit
setPlacementId(placementId: Long)

Définit un ID d'emplacement pour l'annonce interstitielle.

abstract Unit
show(activity: Activity)

Affiche l'annonce interstitielle.

Constructeurs publics

AdManagerInterstitialAd

AdManagerInterstitialAd()

Fonctions publiques

getAppEventListener

abstract fun getAppEventListener(): AppEventListener?

Renvoie le AppEventListener pour ce AdManagerInterstitialAd.

auto-infligée

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

Charge un AdManagerInterstitialAd.

Paramètres
context: Context

Le contexte.

adUnitId: String

ID du bloc d'annonces.

adManagerAdRequest: AdManagerAdRequest

Demande d'annonce avec des informations de ciblage.

loadCallback: AdManagerInterstitialAdLoadCallback

Rappel à appeler lorsqu'une annonce interstitielle Google Ad Manager a fini de se charger.

setAppEventListener

abstract fun setAppEventListener(appEventListener: AppEventListener?): Unit

Définit un AppEventListener pour ce AdManagerInterstitialAd.