InterstitialAd

public abstract class InterstitialAd

इस क्लास से सीधे इनहेरिट करने वाली ज्ञात सबक्लास
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

इस InterstitialAd के लिए FullScreenContentCallback मिलता है.

abstract @Nullable OnPaidEventListener

इस InterstitialAd के लिए OnPaidEventListener मिलता है.

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)

इंटरस्टीशियल विज्ञापन दिखाता है.

सार्वजनिक कंस्ट्रक्टर

InterstitialAd

public InterstitialAd()

सार्वजानिक तरीके

getAdUnitId

public abstract @NonNull String getAdUnitId()

यह विज्ञापन यूनिट आईडी दिखाता है.

getFullScreenContentCallback

public abstract @Nullable FullScreenContentCallback getFullScreenContentCallback()

इस InterstitialAd के लिए FullScreenContentCallback मिलता है.

getOnPaidEventListener

public abstract @Nullable OnPaidEventListener getOnPaidEventListener()

इस InterstitialAd के लिए OnPaidEventListener मिलता है.

getPlacementId

public abstract long getPlacementId()

इस 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)

यह एक कॉलबैक रजिस्टर करता है. इसे तब शुरू किया जाता है, जब यह अनुमान लगाया जाता है कि इस विज्ञापन से कमाई हुई है.

setPlacementId

public abstract void setPlacementId(long placementId)

यह इंटरस्टीशियल विज्ञापन के लिए प्लेसमेंट आईडी सेट करता है.

यह पक्का करने के लिए कि यह प्लेसमेंट आईडी रिपोर्टिंग में शामिल हो, विज्ञापन दिखाने से पहले इस तरीके को कॉल करें.

पैरामीटर
long placementId

यह कॉन्फ़िगर किए गए प्लेसमेंट के लिए, AdMob यूज़र इंटरफ़ेस (यूआई) से मिला एक बड़ा पूर्णांक होता है.

दिखाएं

public abstract void show(@NonNull Activity activity)

इंटरस्टीशियल विज्ञापन दिखाता है.

पैरामीटर
@NonNull Activity activity

विज्ञापन दिखाने के लिए Activity कॉन्टेक्स्ट.