InterstitialAd

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

סיכום

‫constructors ציבוריים

‫methods ציבוריות

abstract @NonNull String

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

abstract @Nullable FullScreenContentCallback

מחזירה את ה-FullScreenContentCallback של ה-InterstitialAd הזו.

abstract @Nullable OnPaidEventListener

מחזירה את ה-OnPaidEventListener של ה-InterstitialAd הזו.

abstract long

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

abstract @NonNull ResponseInfo

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

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

הmethod הזו הוצאה משימוש.

במקום זאת, אתם צריכים להשתמש ב-isAdAvailable.

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

טוענת InterstitialAd.

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

הmethod הזו הוצאה משימוש.

במקום זאת, אתם צריכים להשתמש ב-pollAd.

abstract void

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

abstract void
setImmersiveMode(boolean immersiveModeEnabled)

מגדירה דגל שקובע אם אובייקט הביניים הזה יוצג במצב אימרסיבי.

abstract void

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

abstract void
setPlacementId(long placementId)

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

abstract void
show(@NonNull Activity activity)

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

‫constructors ציבוריים

InterstitialAd

public InterstitialAd()

‫methods ציבוריות

getAdUnitId

public abstract @NonNull String getAdUnitId()

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

getFullScreenContentCallback

public abstract @Nullable FullScreenContentCallback getFullScreenContentCallback()

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

getOnPaidEventListener

public abstract @Nullable OnPaidEventListener getOnPaidEventListener()

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

getPlacementId

public abstract long getPlacementId()

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

getResponseInfo

public abstract @NonNull ResponseInfo getResponseInfo()

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

isAdAvailable

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

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

load

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

טוענת InterstitialAd.

פרמטרים
@NonNull Context context

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

@NonNull String adUnitId

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

@NonNull AdRequest adRequest

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

@NonNull InterstitialAdLoadCallback loadCallback

קריאה חוזרת (callback) שתופעל כשמודעת מעברון תסיים להיטען.

pollAd

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

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

setFullScreenContentCallback

public abstract void setFullScreenContentCallback(
    @Nullable FullScreenContentCallback fullScreenContentCallback
)

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

setImmersiveMode

public abstract void setImmersiveMode(boolean immersiveModeEnabled)

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

setOnPaidEventListener

public abstract void setOnPaidEventListener(@Nullable OnPaidEventListener listener)

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

setPlacementId

public abstract void setPlacementId(long placementId)

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

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

פרמטרים
long placementId

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

show

public abstract void show(@NonNull Activity activity)

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

פרמטרים
@NonNull Activity activity

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