InterstitialAd

public 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 @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)

تعرِض القيمة true إذا كان هناك إعلان بيني متوفّر تم تحميله من startPreload.

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)

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

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

InterstitialAd

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)

تعرِض القيمة true إذا كان هناك إعلان بيني متوفّر تم تحميله من startPreload.

حمولة

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 لعرض الإعلان منه