AdManagerInterstitialAd

abstract class AdManagerInterstitialAd : InterstitialAd


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

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

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

        // Load a Google Ad Manager 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.
        AdManagerInterstitialAd.load(
            this,
            "myAdUnitId",
            new AdManagerAdRequest.Builder().build(),
            new AdManagerInterstitialAdLoadCallback() {
                @Override
                public void onAdLoaded(@NonNull AdManagerInterstitialAd ad) {
                    adManagerInterstitialAd = ad;
                    adManagerInterstitialAd.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 (adManagerInterstitialAd != null) {
                    adManagerInterstitialAd.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 AppEventListener?

يعرض AppEventListener لـ AdManagerInterstitialAd.

java-static Unit
load(
    context: Context,
    adUnitId: String,
    adManagerAdRequest: AdManagerAdRequest,
    loadCallback: AdManagerInterstitialAdLoadCallback
)

يعمل على تحميل AdManagerInterstitialAd.

abstract Unit

يضبط هذه السمة AppEventListener لـ AdManagerInterstitialAd.

الدوال الموروثة

من com.google.android.gms.ads.interstitial.InterstitialAd
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)

يعرِض الإعلان البيني.

طُرق وضع التصميم العامة

AdManagerInterstitialAd

AdManagerInterstitialAd()

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

getAppEventListener

abstract fun getAppEventListener(): AppEventListener?

يعرض AppEventListener لـ AdManagerInterstitialAd.

حمولة

java-static fun load(
    context: Context,
    adUnitId: String,
    adManagerAdRequest: AdManagerAdRequest,
    loadCallback: AdManagerInterstitialAdLoadCallback
): Unit

يعمل على تحميل AdManagerInterstitialAd.

المعلمات
context: Context

السياق

adUnitId: String

رقم تعريف الوحدة الإعلانية.

adManagerAdRequest: AdManagerAdRequest

طلب عرض إعلان يتضمّن معلومات الاستهداف

loadCallback: AdManagerInterstitialAdLoadCallback

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

setAppEventListener

abstract fun setAppEventListener(appEventListener: AppEventListener?): Unit

يضبط هذه السمة AppEventListener لـ AdManagerInterstitialAd.