InterstitialAd

public abstract class InterstitialAd

الفئات الفرعية المباشرة المعروفة
AdManagerInterstitialAd

تجربة إعلان على صفحة كاملة في نقاط انتقال عادية، مثل تغيير الصفحة أو إطلاق تطبيق أو تحميل مستوى لعبة للناشرين على "مدير إعلانات Google"


تجربة إعلان على صفحة كاملة في نقاط انتقال عادية، مثل تغيير الصفحة أو إطلاق تطبيق أو تحميل مستوى لعبة. تستخدِم الإعلانات البينية زر إغلاق يزيل الإعلان من تجربة المستخدم.

نموذج التعليمات البرمجية:

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 @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)

تم إيقاف هذه الطريقة نهائيًا.

استخدِم 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)

تم إيقاف هذه الطريقة نهائيًا.

استخدِم pollAd بدلاً من ذلك.

abstract void

تسجّل هذه السمة دالة ردّ نداء سيتم استدعاؤها عندما تعرض الإعلانات محتوى بملء الشاشة ويتم إغلاقه.

abstract void
setImmersiveMode(boolean immersiveModeEnabled)

تضبط هذه السمة علامة تتحكّم في ما إذا كان سيتم عرض هذا العنصر الإعلاني البيني في الوضع الغامر.

abstract void

تسجِّل هذه الطريقة دالّة ردّ اتصال سيتم استدعاؤها عندما يُقدّر أنّ هذا الإعلان قد حقّق أرباحًا.

abstract void
setPlacementId(long placementId)

تضبط هذه الطريقة معرّف موضع الإعلان البيني.

abstract void
show(@NonNull Activity activity)

تعرِض هذه السمة الإعلان البيني.

الدوال الإنشائية العامة

InterstitialAd

public InterstitialAd()

الطُرق العامة

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.

حمولة

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

دالّة ردّ اتصال سيتم استدعاؤها عند انتهاء تحميل إعلان بيني.

pollAd

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

يستردّ هذا الإجراء الإعلان البيني التالي الذي تم تحميله من startPreload، أو null إذا لم يتوفّر أي إعلان.

setFullScreenContentCallback

public abstract void setFullScreenContentCallback(
    @Nullable FullScreenContentCallback fullScreenContentCallback
)

تسجّل هذه السمة دالة ردّ نداء سيتم استدعاؤها عندما تعرض الإعلانات محتوى بملء الشاشة ويتم إغلاقه.

setImmersiveMode

public abstract void setImmersiveMode(boolean immersiveModeEnabled)

تضبط هذه السمة علامة تتحكّم في ما إذا كان سيتم عرض هذا العنصر الإعلاني البيني في الوضع الغامر. يجب استدعاء هذه الطريقة قبل 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)

تضبط هذه الطريقة معرّف موضع الإعلان البيني.

لضمان تضمين رقم تعريف موضع الإعلان هذا في التقارير، استدعِ هذه الطريقة قبل عرض الإعلان.

المعلمات
long placementId

عدد صحيح طويل توفّره واجهة مستخدم AdMob للموضع الإعلاني الذي تم ضبطه.

إظهار

public abstract void show(@NonNull Activity activity)

تعرِض هذه السمة الإعلان البيني.

المعلمات
@NonNull Activity activity

تمثّل هذه السمة Activity السياق الذي سيُعرض فيه الإعلان.