我试图理解为什么在用户关闭广告后没有调用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: " );
}
答案 0 :(得分:0)
我需要一个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
答案 1 :(得分:0)
对于您理解为结束以及Android
定义为关闭广告的内容存在误解。您的意思是取消广告,而对于Android,关闭广告,由documentation引用为:
用户即将返回应用程序后调用 点击广告。
您可以找到更多信息here。