当我关闭AdMob插页式广告时,我调用的活动会被销毁。我创建了这样的插页式广告:
interstitialAd = new InterstitialAd(this);
interstitialAd.setAdUnitId(AD_UNIT_ID);
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(MY_TEST_DEVICE_HASHED_ID)
.build();
interstitialAd.loadAd(adRequest);
interstitialAd.setAdListener(new AdListener() {
@Override
public void onAdClosed() {
System.out.println("AD getting closed");
}
});
public void show_ad() {
if (interstitialAd.isLoaded()) interstitialAd.show();
}
@Override
protected void onDestroy() {
System.out.println("onDestroy() called");
super.onDestroy();
}
LogCat输出:
07-27 14:39:35.348: I/Ads(5699): Ad opening.
07-27 14:39:35.438: I/chromium(5699): [INFO:async_pixel_transfer_manager_android.cc(56)] Async pixel transfers not supported
07-27 14:39:35.498: I/chromium(5699): [INFO:async_pixel_transfer_manager_android.cc(56)] Async pixel transfers not supported
07-27 14:39:35.498: E/qdutils(5699): FBIOGET_FSCREENINFO failed
07-27 14:39:45.659: D/dalvikvm(5699): GC_FOR_ALLOC freed 3174K, 23% free 11067K/14272K, paused 21ms, total 23ms
07-27 14:39:48.612: I/Ads(5699): Ad closing.
07-27 14:39:48.612: I/System.out(5699): AD getting closed
07-27 14:39:48.622: I/System.out(5699): onDestroy() called
为什么活动会被破坏?
答案 0 :(得分:3)
想出来。我已将|screenSize
添加到活动的android:configChanges
,现在它正常运行。
答案 1 :(得分:0)
我有同样的问题,但解决方案对我有用:
我刚刚在我的清单的AdActivity中添加了android:theme="@android:style/Theme.Translucent"
。
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:theme="@android:style/Theme.Translucent" />