InterstitialAd

abstract class InterstitialAd

מחלקות משנה ישירות מוכרות
AdManagerInterstitialAd

מודעה שמוצגת בדף מלא בנקודות מעבר טבעיות, למשל במעבר בין דפים, בהפעלת האפליקציה או בטעינת שלב במשחק, לבעלי אתרים ב-Google Ad Manager.


מודעה שמוצגת בדף מלא בנקודות מעבר טבעיות, למשל במעבר בין דפים, בהפעלת האפליקציה או בטעינת שלב במשחק. מודעות מעברון כוללות לחצן סגירה שמאפשר למשתמש להסיר את המודעה מחוויית השימוש.

קוד לדוגמה:

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

        // Load an 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.
        InterstitialAd.load(
            this,
            "myAdUnitId",
            new AdRequest.Builder().build(),
            new InterstitialAdLoadCallback() {
                @Override
                public void onAdLoaded(@NonNull InterstitialAd ad) {
                    interstitialAd = ad;
                    interstitialAd.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 (interstitialAd != null) {
                    interstitialAd.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 String

מחזירה את המזהה של יחידת המודעות.

abstract FullScreenContentCallback?

הפונקציה מחזירה את FullScreenContentCallback של InterstitialAd.

abstract OnPaidEventListener?

הפונקציה מחזירה את OnPaidEventListener של InterstitialAd.

abstract Long

מחזירה את מזהה מיקום המודעה של InterstitialAd.

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)

מגדיר מזהה מיקום למודעת מעברון.

abstract Unit
show(activity: Activity)

הצגת מודעת המעברון.

בוני אובייקטים ציבוריים

InterstitialAd

InterstitialAd()

פונקציות גלויות לכולם

getAdUnitId

abstract fun getAdUnitId(): String

מחזירה את המזהה של יחידת המודעות.

getFullScreenContentCallback

abstract fun getFullScreenContentCallback(): FullScreenContentCallback?

הפונקציה מחזירה את FullScreenContentCallback של InterstitialAd.

getOnPaidEventListener

abstract fun getOnPaidEventListener(): OnPaidEventListener?

הפונקציה מחזירה את OnPaidEventListener של InterstitialAd.

getPlacementId

abstract fun getPlacementId(): Long

מחזירה את מזהה מיקום המודעה של InterstitialAd.

getResponseInfo

abstract fun getResponseInfo(): ResponseInfo

מחזירה את האובייקט ResponseInfo של המודעה שנטענה. הפונקציה מחזירה null עד שהמודעה נטענת בהצלחה.

isAdAvailable

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

הפונקציה מחזירה true אם יש מודעת מעברון זמינה שנטענה מ-startPreload.

משקל

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

טעינה של InterstitialAd.

פרמטרים
context: Context

הקשר של פעילות או אפליקציה.

adUnitId: String

מזהה יחידת המודעות.

adRequest: AdRequest

בקשה להצגת מודעה עם פרטי טירגוט.

loadCallback: InterstitialAdLoadCallback

פונקציית קריאה חוזרת שמופעלת כשמודעת מעברון מסיימת להיטען.

pollAd

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

הפונקציה מאחזרת את מודעת המעברון הבאה שנטענה מ-startPreload, או מ-null אם אין מודעה זמינה.

setFullScreenContentCallback

abstract fun setFullScreenContentCallback(
    fullScreenContentCallback: FullScreenContentCallback?
): Unit

רושם קריאה חוזרת להפעלה כשמודעות מוצגות ומסתירות תוכן במסך מלא.

setImmersiveMode

abstract fun setImmersiveMode(immersiveModeEnabled: Boolean): Unit

מגדירה דגל שקובע אם אובייקט הביניים הזה יוצג במצב סוחף. צריך להפעיל את השיטה הזו לפני show. במהלך show, אם הדגל הזה מופעל ויש תמיכה במצב immersive, הדגלים SYSTEM_UI_FLAG_IMMERSIVE_STICKY ו-SYSTEM_UI_FLAG_HIDE_NAVIGATION יופעלו עבור מודעת הביניים.

setOnPaidEventListener

abstract fun setOnPaidEventListener(listener: OnPaidEventListener?): Unit

רושמת קריאה חוזרת להפעלה כשהמערכת מעריכה שהמודעה הזו הניבה רווחים.

setPlacementId

abstract fun setPlacementId(placementId: Long): Unit

מגדיר מזהה מיקום למודעת מעברון.

כדי לוודא שמזהה מיקום המודעה הזה ייכלל בדוחות, צריך להפעיל את השיטה הזו לפני הצגת המודעה.

פרמטרים
placementId: Long

מספר שלם ארוך שמופיע בממשק המשתמש של AdMob למיקום המודעה שהוגדר.

הצג

abstract fun show(activity: Activity): Unit

הצגת מודעת המעברון.

פרמטרים
activity: Activity

Activity הקשר שבו המודעה תוצג.