【问题标题】:ChartBoost Interstitial banner not show in Android Studio ApplicationChartBoost 插页式横幅未显示在 Android Studio 应用程序中
【发布时间】:2017-06-18 04:35:00
【问题描述】:

我正在使用Android Studio 使用Android 应用程序。我在我的 android 应用程序中使用ChartBoost 插页式横幅。 我的代码使用ChartBoost Android SDK 集成链接来集成ChartBoost SDK; 我已正确遵循 chartboost 链接并将 appId 和 appsignature 放在 strings.xml 中。这是我的MainActivity.java

import com.chartboost.sdk.CBLocation;
import com.chartboost.sdk.Chartboost;
import com.chartboost.sdk.ChartboostDelegate;
import com.chartboost.sdk.Libraries.CBLogging;

public class MainMenu extends Activity {

    private InterstitialAd mInterstitialAd, mInterstitialAd1;

    private static final String TAG = "Chartboost";
    // This is the object for Startapp Ads Banner
    private StartAppAd startAppAd = new StartAppAd(this);

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //This is the AppID for Startup Ads Banner
        StartAppSDK.init(this, "xxxxxxxxx", false);
        setContentView(R.layout.activity_menu);

        Chartboost.startWithAppId(this, getResources().getString(R.string.appId), getResources().getString(R.string.appSignature));
        Chartboost.setLoggingLevel(CBLogging.Level.ALL);
        Chartboost.setDelegate(delegate);
        Chartboost.onCreate(this);


        if ( Chartboost.hasInterstitial(CBLocation.LOCATION_DEFAULT) ) {
            Chartboost.showInterstitial(CBLocation.LOCATION_DEFAULT);
        } else {
            Chartboost.cacheInterstitial(CBLocation.LOCATION_DEFAULT);
        }


        AdView mAdView = (AdView) findViewById(R.id.adView);
        AdRequest adRequest = new AdRequest.Builder().build();
        mAdView.loadAd(adRequest);
        mInterstitialAd = new InterstitialAd(this);
        mInterstitialAd.setAdUnitId(getResources().getString(R.string.inter_ad_unit_id));
        mInterstitialAd.setAdListener(new AdListener() {
            @Override
            public void onAdClosed() {
                requestNewInterstitial();
            }
        });
        requestNewInterstitial();

        mInterstitialAd1 = new InterstitialAd(this);
        mInterstitialAd1.setAdUnitId(getResources().getString(R.string.inter_ad_unit_id));
        mInterstitialAd1.setAdListener(new AdListener() {
            @Override
            public void onAdClosed() {
                requestNewInterstitial1();
            }
        });
        requestNewInterstitial1();

        startAppAd.loadAd(new AdEventListener() {
            @Override
            public void onReceiveAd(Ad ad) {
            }

            @Override
            public void onFailedToReceiveAd(Ad ad) {
            }
        });


        Button shareIt = (Button) findViewById(R.id.shareIt);
        shareIt.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                shareIt();
            }
        });


    }

    //-------------- Shareit Button ---------------//
    private void shareIt() {
        mInterstitialAd.show();
        Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
        sharingIntent.setType("text/plain");
        sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Business and Visiting Cards Maker");
        sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, "https://play.google.com/store/apps/details?id=com.ata.business.visiting.cards.maker");
        startActivity(Intent.createChooser(sharingIntent, "Share via"));
    }

    public void click_card(View v) {
        mInterstitialAd.show();
        Intent intent = new Intent(this, MainActivity.class);
        this.startActivity(intent);
    }

    private ChartboostDelegate delegate = new ChartboostDelegate() {

        @Override
        public boolean shouldRequestInterstitial(String location) {
            Log.i(TAG, "SHOULD REQUEST INTERSTITIAL '" + (location != null ? location : "null"));
            return true;
        }

        @Override
        public boolean shouldDisplayInterstitial(String location) {
            Log.i(TAG, "SHOULD DISPLAY INTERSTITIAL '" + (location != null ? location : "null"));
            return true;
        }

        @Override
        public void didCacheInterstitial(String location) {
            Log.i(TAG, "DID CACHE INTERSTITIAL '" + (location != null ? location : "null"));
        }

    };

    @Override
    protected void onStart() {
        super.onStart();
        Chartboost.onStart(this);
    }

    @Override
    public void onResume() {
        super.onResume();
        Chartboost.onResume(this);
    }

    @Override
    public void onPause() {
        super.onPause();
        Chartboost.onPause(this);
    }

    @Override
    public void onStop() {
        super.onStop();
        Chartboost.onStop(this);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        Chartboost.onDestroy(this);
    }


    private void requestNewInterstitial() {
        AdRequest adRequest = new AdRequest.Builder().build();
        mInterstitialAd.loadAd(adRequest);
    }

    private void requestNewInterstitial1() {
        AdRequest adRequest = new AdRequest.Builder().build();
        mInterstitialAd1.loadAd(adRequest);
    }

    @Override
    public boolean onKeyUp(int keyCode, KeyEvent msg) {
        switch (keyCode) {
            case (KeyEvent.KEYCODE_BACK):
                Intent intent = new Intent(this, ExitPanel.class);
                startActivity(intent);
                startAppAd.showAd();
                finish();
                return true;
        }
        return false;
    }
}

在 Android Studio Logcat Interstitial Banner 中已加载,但在我的 Android 设备中未显示 Interstitial Banner。 在 ChartBoost 仪表板中,插页式横幅采用纵向形式。 点击率、展示次数和下载量正在显示。 但问题是 MainActivity.java 中没有显示 Interstitial Banner

谁能告诉我我应该使用哪个位置以及为什么我的 Android 设备或模拟器中没有显示插页式横幅广告的问题是什么? 而且我也尝试过 Hotspot Sheild VPN……但是没用?

【问题讨论】:

  • 您好,如果您在 support@chartboost.com 写信给支持热线,Chartboost 支持将很乐意提供帮助。一旦我们在那里解决了答案,我很乐意回到这里并发布解决方案的 tl;dr 版本。谢谢!

标签: android ads interstitial chartboost


【解决方案1】:
 if (Chartboost.hasInterstitial(CBLocation.LOCATION_DEFAULT) ) {
            Chartboost.showInterstitial(CBLocation.LOCATION_DEFAULT);
  } else {
      Chartboost.cacheInterstitial(CBLocation.LOCATION_DEFAULT);
 }

这只是 Chartboost 插页式广告的一部分。您在做什么,当您的活动开始时,它会检查 Chartboost 是否有任何位置 CBLocation.LOCATION_DEFAULT 的插页式广告,然后它返回 false,因为您没有请求任何此类广告。然后通过 else 部分,您请求 CBLocation.LOCATION_DEFAULT 位置的插页式广告。

一段时间后,可能是您有一个插页式广告,然后当您检查 Chartboost.hasInterstitial(CBLocation.LOCATION_DEFAULT) 的值时返回 true 和 Chartboost.showInterstitial(CBLocation.LOCATION_DEFAULT); 给你看广告。

使用代表的方法告诉您,您的广告已准备好展示。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-03-19
    • 1970-01-01
    • 1970-01-01
    • 2020-06-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多