if Activity is destroyed while the banner is expanded, it will throw a memory leak error:
android.view.WindowLeaked: Activity com.google.android.gms.example.bannerexample.MyActivity has leaked window android.widget.PopupWindow$PopupDecorView{d7bc3fa V.E...... R......D 0,0-1438,1477} that was originally added here (Ask Gemini)
at android.view.ViewRootImpl.<init>(ViewRootImpl.java:733)
at android.view.ViewRootImpl.<init>(ViewRootImpl.java:717)
at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:399)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:109)
at android.widget.PopupWindow.invokePopup(PopupWindow.java:1576)
at android.widget.PopupWindow.showAtLocation(PopupWindow.java:1342)
at android.widget.PopupWindow.showAtLocation(PopupWindow.java:1308)
at com.google.android.gms.ads.internal.gmsg.ar.a(:com.google.android.gms.policy_ads_fdr_dynamite@241199803@241199801034.618989241.618989241:1383)
at com.google.android.gms.ads.internal.webview.r.x(:com.google.android.gms.policy_ads_fdr_dynamite@241199803@241199801034.618989241.618989241:52)
at com.google.android.gms.ads.internal.webview.r.e(:com.google.android.gms.policy_ads_fdr_dynamite@241199803@241199801034.618989241.618989241:100)
at com.google.android.gms.ads.internal.webview.al.run(:com.google.android.gms.policy_ads_fdr_dynamite@241199803@241199801034.618989241.618989241:25)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at m.azn.a(:com.google.android.gms.policy_ads_fdr_dynamite@241199803@241199801034.618989241.618989241:1)
at com.google.android.gms.ads.internal.util.f.a(:com.google.android.gms.policy_ads_fdr_dynamite@241199803@241199801034.618989241.618989241:2)
at m.azn.dispatchMessage(:com.google.android.gms.policy_ads_fdr_dynamite@241199803@241199801034.618989241.618989241:1)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
loadBanner method used in Banner example:
private void loadBanner() {
// Create a new ad view.
adView = new AdView(this);
adView.setAdUnitId(AD_UNIT_ID);
adView.setAdSize(getAdSize());
// Replace ad container with new ad view.
adContainerView.removeAllViews();
adContainerView.addView(adView);
Bundle extras = new Bundle();
extras.putString("collapsible", "bottom");
extras.putString("collapsible_request_id", UUID.randomUUID().toString());
// Start loading the ad in the background.
AdRequest adRequest = new AdRequest.Builder()
.addNetworkExtrasBundle(AdMobAdapter.class, extras)
.build();
adView.loadAd(adRequest);
}
if Activity is destroyed while the banner is expanded, it will throw a memory leak error:
loadBanner method used in Banner example: