【发布时间】: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