مدیر تبلیغاتبینابینی

public abstract class AdManagerInterstitialAd extends InterstitialAd


یک تجربه تبلیغ تمام صفحه در نقاط انتقال طبیعی مانند تغییر صفحه، راه‌اندازی برنامه یا بارگذاری سطح بازی برای ناشران Google Ad Manager. تبلیغات بینابینی از یک دکمه بستن استفاده می‌کنند که تبلیغ را از تجربه کاربر حذف می‌کند.

کد نمونه:

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 @ Nullable AppEventListener

AppEventListener را برای این AdManagerInterstitialAd برمی‌گرداند.

static void
load (
@ NonNull Context context,
@ NonNull String adUnitId,
@ NonNull AdManagerAdRequest adManagerAdRequest,
@ NonNull AdManagerInterstitialAdLoadCallback loadCallback
)

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

abstract void

یک AppEventListener برای این AdManagerInterstitialAd تنظیم می‌کند.

روش‌های ارثی

از com.google.android.gms.ads.interstitial.InterstitialAd
abstract @ NonNull String

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

abstract @ Nullable FullScreenContentCallback

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

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)

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

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

مدیر تبلیغاتبینابینی

public AdManagerInterstitialAd()

روش‌های عمومی

getAppEventListener

public abstract @Nullable AppEventListener getAppEventListener()

AppEventListener را برای این AdManagerInterstitialAd برمی‌گرداند.

بار

public static void load(
    @NonNull Context context,
    @NonNull String adUnitId,
    @NonNull AdManagerAdRequest adManagerAdRequest,
    @NonNull AdManagerInterstitialAdLoadCallback loadCallback
)

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

پارامترها
@ NonNull Context context

زمینه.

@ NonNull String adUnitId

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

@ NonNull AdManagerAdRequest adManagerAdRequest

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

@ NonNull AdManagerInterstitialAdLoadCallback loadCallback

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

setAppEventListener

public abstract void setAppEventListener(@Nullable AppEventListener appEventListener)

یک AppEventListener برای این AdManagerInterstitialAd تنظیم می‌کند.