Android.view.WindowLeaked: activity leaked into the android.widget.ZoomButtonsController $ Container window, which was originally added here

Working with maps I have an activity that starts when there is no connection and uses offline maps (MapQuest). The activity is working fine, the map is displayed and all overlays, markers, etc. When a user clicks on one of the marker information windows, another activity starts, and at that moment I get a bunch of red error messages in the log, although the application does not crash. These messages (init in the header) seem to talk about the ZoomButtons and touch buttons. As for ZoomButtons or touch events (multitouch) in the code, there are only 2 lines:

map.setBuiltInZoomControls(true); map.setMultiTouchControls(true); 

not some kind of dialogue ...

  • if i write:

    map.setBuiltInZoomControls (false); map.setMultiTouchControls (false);

red error messages disappear, but, of course, the user cannot zoom in or out ...

Since the error (with the "true" parameter) occurs only when another activity is started, I thought that I need to add something to on pause (), that is:

 onPause(){ map.setBuiltInZoomControls(false); map.setMultiTouchControls(false); super.OnPause(); } 

---- but that doesn’t change anything ... Any hint ??? - Thanks in advance!

+8
maps osmdroid
Dec 02 '14 at 16:44
source share
3 answers

Add this to your activity:

 @Override public void finish() { ViewGroup view = (ViewGroup) getWindow().getDecorView(); view.removeAllViews(); super.finish(); } 
+15
Feb 11 '15 at 13:10
source share

I had the same problem ... thanks to the fact that you indicated that it was caused (probably) when the zoom controls are still visible. I tested it and it was correct. When I pressed the back button using the zoom buttons, it will show that there is a leak error, if I wait until the controls disappear (they stop scrolling), then there were no leak errors.

A little research in WebSettings provided a method that does not display zoom controls, which means that it does not flow anytime you want to click the back button. However, it still zooms in using the pinch effect. The only drawback to using this method is that your controls will not be displayed. But for me it is worth it, since most users are aware of scaling for all applications.

Here is what I used:

 // make sure your pinch zoom is enabled webView.getSettings().setBuiltInZoomControls(true); // don't show the zoom controls webView.getSettings().setDisplayZoomControls(false); 
+8
Feb 19 '15 at 7:09
source share

The problem with this leak window does not appear in the next version of Android 3.0, so you can try:

  // enabled zoom support getSettings().setSupportZoom(true); getSettings().setBuiltInZoomControls(true); // but,We should hide this button, otherwise in the version // of Android 3 and above, there is a window leak. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { // call requies API Level 11 ( Android 3.0 + ) getSettings().setDisplayZoomControls(false); } 
+1
Jul 07 '16 at 4:59
source share



All Articles