Reputation: 4036
When I close the AdMob interstitial test-ad, the activity I called it from gets destroyed. I create the interstitial like this:
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 output:
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
Why is the activity getting destroyed?
Upvotes: 2
Views: 2257
Reputation: 3444
I had same problem but Solution that worked for me :
i just added android:theme="@android:style/Theme.Translucent"
in AdActivity of my manifest.
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:theme="@android:style/Theme.Translucent" />
Upvotes: 0
Reputation: 4036
Figured it out. I added |screenSize
to android:configChanges
of the activity and now it's working fine.
Upvotes: 3