InterstitialAd

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 String

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

abstract FullScreenContentCallback?

تحصل على FullScreenContentCallback لهذا InterstitialAd.

abstract OnPaidEventListener?

تحصل على OnPaidEventListener لهذا 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
show(activity: Activity)

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

وظائف الإنشاء العامة

InterstitialAd

InterstitialAd()

الوظائف العامة

getAdUnitId

abstract fun getAdUnitId(): String

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

getFullScreenContentCallback

abstract fun getFullScreenContentCallback(): FullScreenContentCallback?

تحصل على FullScreenContentCallback لهذا InterstitialAd.

getOnPaidEventListener

abstract fun getOnPaidEventListener(): OnPaidEventListener?

تحصل على OnPaidEventListener لهذا 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، إذا كان هذا الإعداد مفعّلاً وكان الوضع الشامل متوافقًا، سيتم تفعيل SYSTEM_UI_FLAG_IMMERSIVE_STICKY وSYSTEM_UI_FLAG_HIDE_NAVIGATION للإعلان البيني.

setOnPaidEventListener

abstract fun setOnPaidEventListener(listener: OnPaidEventListener?): Unit

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

إظهار

abstract fun show(activity: Activity): Unit

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

المعلمات
activity: Activity

سياق Activity لعرض الإعلان منه