Android admob插屏问题

cocos2dx版本:2.2.3

admob:google play services

以下是admob插屏广告创建的代码:

public void createInterstitial() {

 // Create an ad.

_interstitialAd = new InterstitialAd(_activity);
_interstitialAd.setAdUnitId(AD_UNIT_ID);

 // Set the AdListener.
 //AdmobInterstitialDelegate delegate = new AdmobInterstitialDelegate();
 _interstitialAd.setAdListener(this);

loadInterstitial();
}

public void loadInterstitial() {

 // Check the logcat output for your hashed device ID to get test ads on a physical device.
 AdRequest adRequest = new AdRequest.Builder()
     .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
     .addTestDevice("D2F0DD3A5275B8E6858EA483DD794D55")
     .build();


 // Load the interstitial ad.
 _interstitialAd.loadAd(adRequest);

}

以上代码是在oncreate里调用,但是没有在请求广告成功后立即将插屏广告显示出来,而是在出现某个场景后通过jni调用以下的方法来显示插屏广告。

public void showInterstitial() {
if (
_interstitialAd.isLoaded()) {
_interstitialAd.show();
} else {
Log.d(“Interstitial”, “Interstitial ad was not ready to be shown.”);
}
}

但是,当在执行_interstitialAd.isLoaded()的时候却是出错了。

还请大神指点下!!!

:904: 没人回答。。。

问题解决了,把解决方法贴出来造福后来人。
由于Android主线程是线程不安全的,所以要通过cocosd的加你来调用admob广告显示,需要创建Handler来刷新UI。
代码:
Handler myHandler = new Handler() {
public void handleMessage(Message msg) {
switch (msg.what) {
case 0:

if (_interstitialAd.isLoaded()) {
_interstitialAd.show();
} else {
Tools.Log(“Interstitial”, “Interstitial ad was not ready to be shown.”);
}
break;
}
super.handleMessage(msg);
}
};

跪求完整傻瓜中文方法:6::6::6:

还没插过广告,留名!!