InterstitialAd

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 String

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

abstract FullScreenContentCallback?

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

abstract OnPaidEventListener?

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

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
setFullScreenContentCallback(
    fullScreenContentCallback: FullScreenContentCallback?
)

यह कुकी, एक कॉलबैक रजिस्टर करती है. इसे तब शुरू किया जाता है, जब विज्ञापन, फ़ुल स्क्रीन कॉन्टेंट दिखाते हैं और उसे खारिज करते हैं.

abstract Unit
setImmersiveMode(immersiveModeEnabled: Boolean)

यह फ़्लैग सेट करता है. इससे यह कंट्रोल किया जाता है कि यह इंटरस्टीशियल ऑब्जेक्ट, इमर्सिव मोड में दिखेगा या नहीं.

abstract Unit

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

abstract Unit
setPlacementId(placementId: Long)

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

abstract Unit
show(activity: Activity)

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

पब्लिक कंस्ट्रक्टर

InterstitialAd

InterstitialAd()

पब्लिक फ़ंक्शन

getAdUnitId

abstract fun getAdUnitId(): String

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

getFullScreenContentCallback

abstract fun getFullScreenContentCallback(): FullScreenContentCallback?

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

getOnPaidEventListener

abstract fun getOnPaidEventListener(): OnPaidEventListener?

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

getPlacementId

abstract fun getPlacementId(): Long

इस InterstitialAd के लिए प्लेसमेंट आईडी दिखाता है.

getResponseInfo

abstract fun getResponseInfo(): ResponseInfo

लोड किए गए विज्ञापन के लिए ResponseInfo ऑब्जेक्ट दिखाता है. विज्ञापन लोड होने तक null दिखाता है.

isAdAvailable

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

अगर true से लोड किया गया कोई इंटरस्टीशियल विज्ञापन उपलब्ध है, तो true दिखाता है.startPreload

लोड

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

InterstitialAd लोड करता है.

पैरामीटर
context: Context

किसी गतिविधि या ऐप्लिकेशन का कॉन्टेक्स्ट.

adUnitId: String

विज्ञापन यूनिट का आईडी.

adRequest: AdRequest

टारगेटिंग (विज्ञापन के लिए सही दर्शक चुनना) की जानकारी वाला विज्ञापन अनुरोध.

loadCallback: InterstitialAdLoadCallback

इंटरस्टीशियल विज्ञापन लोड होने पर, इस कॉलबैक को शुरू किया जाएगा.

pollAd

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

यह startPreload से लोड किए गए अगले इंटरस्टीशियल विज्ञापन को वापस लाता है. अगर कोई विज्ञापन उपलब्ध नहीं है, तो यह null को वापस लाता है.

setFullScreenContentCallback

abstract fun setFullScreenContentCallback(
    fullScreenContentCallback: FullScreenContentCallback?
): Unit

यह कुकी, एक कॉलबैक रजिस्टर करती है. इसे तब शुरू किया जाता है, जब विज्ञापन, फ़ुल स्क्रीन कॉन्टेंट दिखाते हैं और उसे खारिज करते हैं.

setImmersiveMode

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

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

setPlacementId

abstract fun setPlacementId(placementId: Long): Unit

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

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

पैरामीटर
placementId: Long

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

दिखाएं

abstract fun show(activity: Activity): Unit

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

पैरामीटर
activity: Activity

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