Admob插页式广告在我的Android应用中无效

时间:2014-04-06 12:43:12

标签: android admob interstitial

我从此处https://developers.google.com/mobile-ads-sdk/docs/admob/advanced复制了插页式广告的代码,但它不起作用。当应用程序调用方法interstitial.isLoaded()时,它会崩溃。这是logcat:

04-06 14:40:09.320  29704-30638/? W/dalvikvm﹕ threadid=16: thread exiting with uncaught exception (group=0x4145e438)
04-06 14:40:09.330  29704-30638/? E/AndroidRuntime﹕ FATAL EXCEPTION: Thread-3225
    java.lang.IllegalStateException: isLoaded must be called on the main UI thread.
            at bkm.b(SourceFile:174)
            at xx.e(SourceFile:210)
            at yh.onTransact(SourceFile:66)
            at android.os.Binder.transact(Binder.java:326)
            at com.google.android.gms.internal.ac$a$a.isReady(Unknown Source)
            at com.google.android.gms.ads.InterstitialAd.isLoaded(Unknown Source)
            at com.MyApp.GameActivity.displayInterstitial(GameActivity.java:75)
            at com.MyApp.GameActivity$GameView.onDraw(GameActivity.java:300)
            at com.MyApp.GameActivity$GameLoop.run(GameActivity.java:524)
04-06 14:40:09.330     441-4437/? W/ActivityManager﹕ Force finishing activity...

怎么可能?能否请您逐步向我解释我必须做些什么来展示这个插页式广告? 提前谢谢

1 个答案:

答案 0 :(得分:0)

分享我的案例和解决方案

我从其他线程调用它并得到此错误。 我解决了我使用Message从其他线程发送到主线程(服务/活动)。然后在主线程中使消息处理程序调用isLoaded()。这是工作。