插页式广告的监听器的onAdLoaded()将无法运行 [英] Interstitial Ad's Listener's onAdLoaded() won't run

查看:470
本文介绍了插页式广告的监听器的onAdLoaded()将无法运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  interstitial.setAdListener(新AdListener(){
    公共无效onAdLoaded(){
        显示();
    }
});
 

我试着用调试器,1号线在运行,但第二条线是根本无法运行。这是我的初始化广告在onCreate方法:

 间质性=新InterstitialAd(本);
interstitial.setAdUnitId(*********);
AdRequest adRequest =新AdRequest.Builder()建立()。
interstitial.loadAd(adRequest);
 

InterstitialAd间质性; 在类中的方法之外。该AdUnitId故意冲压出来。

logcat的:

  05-17 20:10:49.802:E / GooglePlayServicesUtil(17509):在谷歌播放均未发现服务的资源。检查项目配置,以确保资源被包括在内。
05-17 20:10:49.807:E / GooglePlayServicesUtil(17509):在谷歌播放均未发现服务的资源。检查项目配置,以确保资源被包括在内。
05-17 20:10:51.597:I / GATE(17509):其中,GATE-M> DEV_ACTION_COMPLETED< / GATE-M>
05-17 20:10:51.597:I /广告(17509):调度广告刷新60000毫秒从现在开始。
05-17 20:10:51.602:I /广告(17509):广告加载完毕。
05-17 20:10:51.632:D / TilesManager(17509):启动TG#0,0x5b3446f0
05-17 20:10:51.632:D / TilesManager(17509):从框架新EGLContext:593202c0
05-17 20:10:51.632:D / GLWebViewState(17509):重新初始化着色器
05-17 20:10:51.632:D / GLWebViewState(17509):REINIT transferQueue
05-17 20:10:56.262:D / AbsListView(17509):获取MotionRecognitionManager
05-17 20:11:31.987:I /广告(17509):广告是不可见的。不刷新的广告。
05-17 20:11:31.992:I /广告(17509):调度广告刷新60000毫秒从现在开始。
 

解决方案

使用下面的code,以显示广告的监听器上AdLoaded()。我用同样的。它是为我工作。

 保护无效的onCreate(包savedInstanceState){
super.onCreate(savedInstanceState);

间质性=新InterstitialAd(本);
interstitial.setAdUnitId(***********);

AdRequest adRequest =新AdRequest.Builder()建立()。
interstitial.loadAd(adRequest);
interstitial.setAdListener(新AdListener(){
公共无效onAdLoaded(){
displayInterstitial();
}
});
}
 

外的下code的OnCreate功能用途:

 公共无效displayInterstitial(){
如果(interstitial.isLoaded()){
interstitial.show();
}
}
 

interstitial.setAdListener(new AdListener(){
    public void onAdLoaded(){
        display();
    }
});

I tried with the debugger, the 1st line was run, but the second line was simply not run. This is how I initialize the ad in the onCreate method:

interstitial = new InterstitialAd(this);
interstitial.setAdUnitId("******************************");
AdRequest adRequest = new AdRequest.Builder().build();
interstitial.loadAd(adRequest);

and InterstitialAd interstitial; outside of the method inside the class. The AdUnitId was deliberately blanked out.

Logcat:

05-17 20:10:49.802: E/GooglePlayServicesUtil(17509): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
05-17 20:10:49.807: E/GooglePlayServicesUtil(17509): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
05-17 20:10:51.597: I/GATE(17509): <GATE-M>DEV_ACTION_COMPLETED</GATE-M>
05-17 20:10:51.597: I/Ads(17509): Scheduling ad refresh 60000 milliseconds from now.
05-17 20:10:51.602: I/Ads(17509): Ad finished loading.
05-17 20:10:51.632: D/TilesManager(17509): Starting TG #0, 0x5b3446f0
05-17 20:10:51.632: D/TilesManager(17509): new EGLContext from framework: 593202c0 
05-17 20:10:51.632: D/GLWebViewState(17509): Reinit shader
05-17 20:10:51.632: D/GLWebViewState(17509): Reinit transferQueue
05-17 20:10:56.262: D/AbsListView(17509): Get MotionRecognitionManager
05-17 20:11:31.987: I/Ads(17509): Ad is not visible. Not refreshing ad.
05-17 20:11:31.992: I/Ads(17509): Scheduling ad refresh 60000 milliseconds from now.

解决方案

Use the following code to display the ad's listener on AdLoaded(). I used the same. It was worked for me.

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

interstitial = new InterstitialAd(this);
interstitial.setAdUnitId("***********");

AdRequest adRequest = new AdRequest.Builder().build();
interstitial.loadAd(adRequest);
interstitial.setAdListener(new AdListener() {
public void onAdLoaded() {
displayInterstitial();
}
});
}

Outside oncreate function use below code:

public void displayInterstitial() {
if (interstitial.isLoaded()) {
interstitial.show();
}
}

这篇关于插页式广告的监听器的onAdLoaded()将无法运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆