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

public 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 @ NonNull String

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

abstract @ Nullable FullScreenContentCallback

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

abstract @ Nullable OnPaidEventListener

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

abstract @ NonNull ResponseInfo

شی ResponseInfo را برای تبلیغ بارگذاری شده برمی گرداند.

static boolean
isAdAvailable (@ NonNull Context context, @ NonNull String adUnitId)

در صورتی که یک آگهی بینابینی در دسترس از startPreload بارگیری شده باشد، true برمی‌گرداند.

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)

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

abstract void

زمانی که آگهی‌ها محتوای تمام صفحه را نشان می‌دهند و آن را رد می‌کنند، یک تماس برگشتی ثبت می‌کند تا فراخوانی شود.

abstract void
setImmersiveMode (boolean immersiveModeEnabled)

پرچمی را تنظیم می کند که کنترل می کند آیا این شی بینابینی در حالت غوطه ور نمایش داده می شود.

abstract void

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

abstract void
show (@ NonNull Activity activity)

آگهی بینابینی را نشان می دهد.

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

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

public InterstitialAd()

روش های عمومی

getAdUnitId

public abstract @NonNull String getAdUnitId()

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

getFullScreenContentCallback

public abstract @Nullable FullScreenContentCallback getFullScreenContentCallback()

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

getOnPaidEventListener

public abstract @Nullable OnPaidEventListener getOnPaidEventListener()

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

getResponseInfo

public abstract @NonNull ResponseInfo getResponseInfo()

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

isAdAvailable است

public static boolean isAdAvailable(@NonNull Context context, @NonNull String adUnitId)

در صورتی که یک آگهی بینابینی در دسترس از startPreload بارگیری شده باشد، true برمی‌گرداند.

بار

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)

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

نشان می دهد

public abstract void show(@NonNull Activity activity)

آگهی بینابینی را نشان می دهد.

پارامترها
@ NonNull Activity activity

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