我想向第一次下载该应用的用户显示插页式广告。这只会显示一次。
我编写了代码来确定用户是否是第一次使用的用户。 - 哪个工作正常。
我的 displayInterstitial()方法返回 AD未加载? - interstitial.isLoaded()为false,因此 interstitial.show()不会被调用。
我在oncreate中有 loadAd(),因此在这种情况下 displayInterstitial()应该有效。但它没有。
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.inbox_list);
createAdmobBanner();
// Create the interstitial.
interstitial = new InterstitialAd(this);
interstitial.setAdUnitId("ca-app-pub-xxxx/xxx");
// Create ad request.
AdRequest adRequestIN = new AdRequest.Builder().build();
// Begin loading your interstitial.
interstitial.loadAd(adRequestIN);
//CHECK IF USER DOWNLOADED APP FOR FIRST TIME.
SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
if (settings.getBoolean("my_first_time", true)) {
//the app is being launched for first time, do something
Log.d("Comments", "First time");
//CALL LARGE SCREEN ADD
displayInterstitial();
// record the fact that the app has been started at least once
settings.edit().putBoolean("my_first_time", false).commit();
}
// Set an AdListener.
interstitial.setAdListener(new AdListener() {
@Override
public void onAdLoaded() {
}
@Override
public void onAdClosed() {
// Proceed to the next level.
// Create ad request.
AdRequest adRequestIN = new AdRequest.Builder().build();
// Begin loading your interstitial.
interstitial.loadAd(adRequestIN);
}
});
//SHOW ADD
public void displayInterstitial()
{
if (interstitial.isLoaded())
{
interstitial.show();
Log.d("response", "AD IS LOADED: ");
}
else
{
Log.d("response", "AD IS NOT LOADED: " );
}
}
答案 0 :(得分:1)
您在广告加载前致电displayInterstitial()
。
插页式广告需要一些时间才能加载。
您试图过早显示它。