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 السياق الذي سيُعرض فيه الإعلان.