我想了解为什么在用户关闭广告后不会调用 onAdClosed()?
我将尝试创建一个新的 InterstitialAd,稍后使用 display 方法加载和显示。
任何建议都很好,谢谢大家。
代码
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-xxxxx/xxx");
// Create ad request.
AdRequest adRequestIN = new AdRequest.Builder().build();
// Begin loading your interstitial.
interstitial.loadAd(adRequestIN);
// Invoke displayInterstitial() when you are ready to display an interstitial.
public void displayInterstitial()
{
if (interstitial.isLoaded())
{
interstitial.show();
Log.d("response", "AD IS LOADED: ");
}
else
{
Log.d("response", "AD IS NOT LOADED: " );
}
}
public void onAdClosed()
{
// Create the interstitial.
interstitial = new InterstitialAd(this);
interstitial.setAdUnitId("ca-app-pub-xxxxx/xxxx");
// Create ad request.
AdRequest adRequestIN = new AdRequest.Builder().build();
// Begin loading your interstitial.
interstitial.loadAd(adRequestIN);
Log.d("response", "onAdClosed: " );
}
最佳答案
它需要一个 AdListener。
// Set an AdListener.
mInterstitialAd.setAdListener(new AdListener() {
@Override
public void onAdLoaded() {
Toast.makeText(MyActivity.this,
"The interstitial is loaded", Toast.LENGTH_SHORT).show();
}
@Override
public void onAdClosed() {
// Proceed to the next level.
goToNextLevel();
}
});
对初学者无用的链接:(不工作) https://developers.google.com/android/reference/com/google/android/gms/ads/InterstitialAd
关于android - onAdClosed() 没有在应用程序中被调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31837352/