تبلیغات بینابینی

abstract class InterstitialAd

زیرکلاس‌های مستقیم شناخته‌شده AdManagerInterstitialAd
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");
    }
}

خلاصه

سازندگان عمومی

کارکردهای عمومی

abstract String

شناسه واحد تبلیغ را برمی‌گرداند.

abstract FullScreenContentCallback ?

برای این InterstitialAd مقدار FullScreenContentCallback را دریافت می‌کند.

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

یک فراخوانی مجدد ثبت می‌کند تا هنگام نمایش و رد محتوای تمام صفحه توسط تبلیغات، فراخوانی شود.

abstract Unit
setImmersiveMode (immersiveModeEnabled: Boolean )

پرچمی را تنظیم می‌کند که کنترل می‌کند آیا این شیء بینابینی در حالت فراگیر نمایش داده شود یا خیر.

abstract Unit

یک تابع فراخوانی ثبت می‌کند تا زمانی که تخمین زده شود این تبلیغ درآمد کسب کرده است، فراخوانی شود.

abstract Unit
setPlacementId (placementId: Long )

یک شناسه قرارگیری برای تبلیغ بینابینی تنظیم می‌کند.

abstract Unit
show (activity: Activity )

تبلیغ بینابینی را نشان می‌دهد.

سازندگان عمومی

تبلیغات بینابینی

InterstitialAd()

کارکردهای عمومی

دریافت شناسه واحد تبلیغات

abstract fun getAdUnitId(): String

شناسه واحد تبلیغ را برمی‌گرداند.

فراخوانی برگشتی محتوای تمام‌صفحه

abstract fun getFullScreenContentCallback(): FullScreenContentCallback?

برای این InterstitialAd مقدار FullScreenContentCallback را دریافت می‌کند.

getOnPaidEventListener

abstract fun getOnPaidEventListener(): OnPaidEventListener?

OnPaidEventListener برای این InterstitialAd دریافت می‌کند.

دریافت شناسه‌ی مکان

abstract fun getPlacementId(): Long

شناسه قرارگیری برای این InterstitialAd را برمی‌گرداند.

دریافت اطلاعات پاسخ

abstract fun getResponseInfo(): ResponseInfo

شیء ResponseInfo را برای تبلیغ بارگذاری شده برمی‌گرداند. تا زمانی که تبلیغ با موفقیت بارگذاری نشود، null را برمی‌گرداند.

موجود است

java-static fun isAdAvailable(context: Context, adUnitId: String): Boolean

اگر یک تبلیغ بینابینی از startPreload بارگذاری شده باشد، true را برمی‌گرداند.

بار

java-static fun load(
    context: Context,
    adUnitId: String,
    adRequest: AdRequest,
    loadCallback: InterstitialAdLoadCallback
): Unit

یک InterstitialAd را بارگذاری می‌کند.

پارامترها
context: Context

یک فعالیت یا زمینه برنامه.

adUnitId: String

شناسه واحد تبلیغاتی.

adRequest: AdRequest

درخواست تبلیغ به همراه اطلاعات هدف‌گیری.

loadCallback: InterstitialAdLoadCallback

یک فراخوانی برگشتی که پس از اتمام بارگذاری یک تبلیغ بینابینی فراخوانی می‌شود.

نظرسنجی

java-static fun pollAd(context: Context, adUnitId: String): InterstitialAd?

تبلیغ بینابینی بعدی که از startPreload بارگذاری شده است را بازیابی می‌کند، یا اگر تبلیغی در دسترس نباشد null برمی‌گرداند.

فراخوانی برگشتی محتوای تمام‌صفحه

abstract fun setFullScreenContentCallback(
    fullScreenContentCallback: FullScreenContentCallback?
): Unit

یک فراخوانی مجدد ثبت می‌کند تا هنگام نمایش و رد محتوای تمام صفحه توسط تبلیغات، فراخوانی شود.

حالت فراگیر (ImmersiveMode) را تنظیم کنید

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 setPlacementId(placementId: Long): Unit

یک شناسه قرارگیری برای تبلیغ بینابینی تنظیم می‌کند.

برای اطمینان از اینکه این شناسه‌ی قرارگیری در گزارش‌دهی لحاظ شده است، قبل از نمایش تبلیغ، این متد را فراخوانی کنید.

پارامترها
placementId: Long

یک عدد صحیح طولانی که توسط رابط کاربری AdMob برای مکان‌یابی پیکربندی‌شده ارائه شده است.

نشان دادن

abstract fun show(activity: Activity): Unit

تبلیغ بینابینی را نشان می‌دهد.

پارامترها
activity: Activity

یک زمینه Activity که از آن می‌توان تبلیغ را ارائه داد.