AdManagerInterstitialAd

abstract class AdManagerInterstitialAd : InterstitialAd


Experiencia de anuncio de página completa en puntos de transición naturales, como un cambio de página, el inicio de una app o la carga de un nivel de juego para los publicadores de Google Ad Manager. Los anuncios intersticiales usan un botón de cierre que quita el anuncio de la experiencia del usuario.

Código de muestra:

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

Resumen

Constructores públicos

Funciones públicas

abstract AppEventListener?

Devuelve el AppEventListener para este AdManagerInterstitialAd.

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

Carga un AdManagerInterstitialAd.

abstract Unit

Establece un AppEventListener para este AdManagerInterstitialAd.

Funciones heredadas

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

Devuelve el ID de la unidad de anuncios.

abstract FullScreenContentCallback?

Obtiene el FullScreenContentCallback para este InterstitialAd.

abstract OnPaidEventListener?

Obtiene el OnPaidEventListener para este InterstitialAd.

abstract Long

Devuelve el ID de la posición de este InterstitialAd.

abstract ResponseInfo

Devuelve el objeto ResponseInfo del anuncio cargado.

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

Esta función es obsoleta.

Usa isAdAvailable en su lugar.

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

Carga un InterstitialAd.

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

Esta función es obsoleta.

Usa pollAd en su lugar.

abstract Unit
setFullScreenContentCallback(
    fullScreenContentCallback: FullScreenContentCallback?
)

Registra una devolución de llamada para que se invoque cuando los anuncios muestren y descarten contenido de pantalla completa.

abstract Unit
setImmersiveMode(immersiveModeEnabled: Boolean)

Establece una marca que controla si este objeto intersticial se mostrará en el modo envolvente.

abstract Unit

Registra una devolución de llamada para que se invoque cuando se estime que este anuncio generó dinero.

abstract Unit
setPlacementId(placementId: Long)

Establece un ID de posición para el anuncio intersticial.

abstract Unit
show(activity: Activity)

Muestra el anuncio intersticial.

Constructores públicos

AdManagerInterstitialAd

AdManagerInterstitialAd()

Funciones públicas

getAppEventListener

abstract fun getAppEventListener(): AppEventListener?

Devuelve el AppEventListener para este AdManagerInterstitialAd.

load

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

Carga un AdManagerInterstitialAd.

Parámetros
context: Context

El contexto

adUnitId: String

Es el ID de la unidad de anuncios.

adManagerAdRequest: AdManagerAdRequest

Es una solicitud de anuncio con información de segmentación.

loadCallback: AdManagerInterstitialAdLoadCallback

Es una devolución de llamada que se invoca cuando termina de cargarse un anuncio intersticial de Google Ad Manager.

setAppEventListener

abstract fun setAppEventListener(appEventListener: AppEventListener?): Unit

Establece un AppEventListener para este AdManagerInterstitialAd.