AdManagerInterstitialAd

abstract class AdManagerInterstitialAd : InterstitialAd


Pengalaman iklan halaman penuh pada titik transisi alami seperti pergantian halaman, peluncuran aplikasi, atau pemuatan level game untuk penayang Google Ad Manager. Iklan interstisial menggunakan tombol tutup yang menghapus iklan dari pengalaman pengguna.

Contoh kode:

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

Ringkasan

Konstruktor publik

Fungsi publik

abstract AppEventListener?

Menampilkan AppEventListener untuk AdManagerInterstitialAd ini.

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

Memuat AdManagerInterstitialAd.

abstract Unit

Menetapkan AppEventListener untuk AdManagerInterstitialAd ini.

Fungsi yang diwariskan

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

Menampilkan ID unit iklan.

abstract FullScreenContentCallback?

Mendapatkan FullScreenContentCallback untuk InterstitialAd ini.

abstract OnPaidEventListener?

Mendapatkan OnPaidEventListener untuk InterstitialAd ini.

abstract Long

Menampilkan ID penempatan untuk InterstitialAd ini.

abstract ResponseInfo

Menampilkan objek ResponseInfo untuk iklan yang dimuat.

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

Fungsi ini tidak digunakan lagi.

Sebagai gantinya, gunakan isAdAvailable.

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

Memuat InterstitialAd.

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

Fungsi ini tidak digunakan lagi.

Sebagai gantinya, gunakan pollAd.

abstract Unit
setFullScreenContentCallback(
    fullScreenContentCallback: FullScreenContentCallback?
)

Mendaftarkan callback untuk dipanggil saat iklan menampilkan dan menutup konten layar penuh.

abstract Unit
setImmersiveMode(immersiveModeEnabled: Boolean)

Menetapkan tanda yang mengontrol apakah objek interstisial ini akan ditampilkan dalam mode imersif.

abstract Unit

Mendaftarkan callback untuk dipanggil saat iklan ini diperkirakan telah menghasilkan uang.

abstract Unit
setPlacementId(placementId: Long)

Menetapkan ID penempatan untuk iklan interstisial.

abstract Unit
show(activity: Activity)

Menampilkan iklan interstisial.

Konstruktor publik

AdManagerInterstitialAd

AdManagerInterstitialAd()

Fungsi publik

getAppEventListener

abstract fun getAppEventListener(): AppEventListener?

Menampilkan AppEventListener untuk AdManagerInterstitialAd ini.

load

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

Memuat AdManagerInterstitialAd.

Parameter
context: Context

Konteksnya.

adUnitId: String

ID unit iklan.

adManagerAdRequest: AdManagerAdRequest

Permintaan iklan dengan informasi penargetan.

loadCallback: AdManagerInterstitialAdLoadCallback

Callback yang akan dipanggil saat iklan interstisial Google Ad Manager selesai dimuat.

setAppEventListener

abstract fun setAppEventListener(appEventListener: AppEventListener?): Unit

Menetapkan AppEventListener untuk AdManagerInterstitialAd ini.