I'm using a system overlay to show a notification icon, when the user has an application-wide alert When activity is destroyed, I get a leaked window, though I'm removing the view.
The code is in an original activity that is enhanced by most other activities in the app.
Create protected void Make Overlay () (if (Overlay Created) return; // system overlay video window manager. Leautparams Params = new window manager. Leautparms (window manager. Leautparmjh. Filojhar, 150 window Manager. Leautparms. Tiipi_swaitim_aaeliarti, window manager. Leautparmjh. Felaji_oanafosiyuesbl | window manager. Leautparmskflag_oantitiaiacaimadiael, PicSay Format: Gravity.Patams.gravity = Gravity.BOTTOM; Layout Infolator Inflight = (LayoutsInflator) getSystemService (LAYOUT_INFLATER_SERVICE); Mowrele = (linear layout) inflater.inflate (R.Late overlay_notification, empty); Mowrele ImageView = (ImageView) MOverlay.findViewById (RID overlay_notification_isge); WindowManager wm = (WindowManager) getSystemService (WINDOW_SERVICE); Wm.addView (moverley, params); last reference references = this; mOverlay.setOnTouchListener (New View.OnTouchListener () {@Override Public Boolean OnTouch (see V, MotionEvent event) { Toast.makeText (Reference, "WootHa!", Toast.LENGTH_SHORT) .show (); Return true;}}); }
delete
@Override on public void (Destroy) {super.onDestroy (); // Remove the view from the Window Manager if (Mowrele! = Null) {Window Manager wm = (WindowManager) getSystemService (WINDOW_SERVICE); Wm.removeView (mOverlay); Moverle = null; MOverlayImageView = Faucet; }}
Error:
26,576-26,576 / com.letstruck.mygauges E / WindowManager: android.view.WindowLeaked: Activity com.letstruck.mygauges .ui.activity.fuel.TruckListActivity window window Widget Litor Layout (431c4220 VE .... ...... I 0,0-1080,150} is that the original form is added here on lt android.view.ViewRootImpl and; init & gt; android.view on .WindowManagerGlobal.addView (WindowManagerGlobal.java:267) (ViewRootImpl.java:457) on Com.letstruck.mygauges.ui.activity.LoggedInActivity.createOverlay on android.view. WindowManagerImpl.addView (WindowManagerImpl.java:69) com. log on letstruck.mygauges.ui.activity.LoggedInActivity.onOptionsItemSelectedMain (Login Inactive.java:125) has Gyakanukrmnkjawa: com.letstruck.mygauges.ui.activity.fuel on android.support.v4.app 186) atruckListActivity.onOptionsItemSelected (TruckListActivity.java:100) android.app.Activity.onMenuItemSelected (Activity.java:2687). FragmentActivity.onMenuItemSelected com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected (PhoneWindow.java:1103) at (FragmentActivity.java:373) com.android.internal.view.menu.MenuBuilder.dispatchMenuItemSelected at com.android.internal com.android.internal on .view.menu.MenuBuilder.performItemAction (MenuBuilder.java:874) on com.android.internal.view.menu.MenuItemImpl.invoke (MenuItemImpl.java:152) (MenuBuilder.java:735) .view.menu.ListMenuPresenter.onItemClick android.widget.AdapterView.performItemClick (AdapterView.java:308) android.widget.AbsListView.performItemClick on (ListMenuPresenter.java:177) (AbsListView.java:1483) android.widget on android .AbsListView .os.Handler on android.widget.AbsListView $ PerformClick.run (AbsListView.java:3485) (AbsListView.java:4843) android.os.Handler.handleCallback (Handler.java:733) at $ 3.run .dispatchMessage at android.os.Looper.loop (Handler.java:95) (Looper.java: 157) at android.app.ActivityThread.main (ActivityThread.java.ed356) at java.lang.reflect. Method.invokeNative (original method) on Java.lang.reflect.Method. Please call Com.android.internal.os.ZygoteInit at $ MethodAndArgsCaller.run (Vidhikjawa / 15). .system.NativeStart.main (Native Method on Com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1081) Dalvik)
I had the same issue. In my case, I used wm.removeViewImmediate (View) instead of removeView (see) which was solved my problem. Perhaps you can try that.
No comments:
Post a Comment