如何加载和显示inmobi插页式广告

时间:2017-08-03 12:57:49

标签: android inmobi

我是InMobi的新用户我会在android studio中显示插页式广告,然后按照此操作 https://support.inmobi.com/monetize/android-guidelines/interstitial-ads-for-android/ 但是无法准确理解如何将其整合到活动线内的活动中?

有人给出例子 我想整合现有项目

InMobiInterstitial interstitialAd = new InMobiInterstitial(InterstitialAdsActivity.this, 1471550843414L, mInterstitialAdListener);

1 个答案:

答案 0 :(得分:0)

设置插页式广告

  1. 要展示插页式广告,您需要插页式展示位置ID。
  2. 添加应用后,选择INTERSTITIAL AD为广告类型非页内广告创建展示位置。
  3. 成功创建展示位置后,展示位置ID可用。
  4. 在您的应用中添加插页式广告

    在您的活动的oncreate()方法中添加以下代码:

    InMobiInterstitial interstitial = new InMobiInterstitial(this, placement_id, new InMobiInterstitial.InterstitialAdListener2() {
            @Override
            public void onAdRewardActionCompleted(InMobiInterstitial ad, Map rewards) {}
            @Override
            public void onAdDisplayed(InMobiInterstitial ad) {
                Log.d(TAG, "onAdDisplayed: ");
            }
            @Override
            public void onAdDismissed(InMobiInterstitial ad) {
                Log.d(TAG, "onAdDismissed: ");
            }
            @Override
            public void onAdInteraction(InMobiInterstitial ad, Map params) {}
            @Override
            public void onAdLoadSucceeded(final InMobiInterstitial ad) {
                Log.d(TAG, "onAdLoadSucceeded: ");
            }
    
            @Override
            public void onAdDisplayFailed(InMobiInterstitial inMobiInterstitial) {
                Log.d(TAG, "onAdDisplayFailed: ");
            }
    
            @Override
            public void onAdWillDisplay(InMobiInterstitial inMobiInterstitial) {
                Log.d(TAG, "onAdWillDisplay: ");
            }
    
            @Override
            public void onAdLoadFailed(InMobiInterstitial ad, InMobiAdRequestStatus requestStatus) {
                Log.d(TAG, "onAdLoadFailed: " + requestStatus.getMessage());
            }
    
            @Override
            public void onAdReceived(InMobiInterstitial inMobiInterstitial) {
                Log.d(TAG, "onAdReceived: ");
            }
    
            @Override
            public void onUserLeftApplication(InMobiInterstitial ad){
                Log.d(TAG, "onUserLeftApplication: ");
            }
        });
        interstitial.load();
        if(interstitial.isReady())
            interstitial.show();