java - Removing Android system overlay activity -
i have activity have set system overlay. i'm able display it, can't seem figure out how remove when want (via button).
the system overlay displayed in activity's oncreate() method follows:
final windowmanager.layoutparams params = new windowmanager.layoutparams( windowmanager.layoutparams.match_parent, windowmanager.layoutparams.match_parent, windowmanager.layoutparams.type_system_alert, windowmanager.layoutparams.flag_not_touch_modal, pixelformat.opaque); windowmanager wm = (windowmanager)getapplicationcontext().getsystemservice(context.window_service); view mtopview = (viewgroup) getlayoutinflater().inflate(r.layout.overlay, null); getwindow().setattributes(params); wm.addview(mtopview, params);
i have button in activity's layout xml file onclick call method dook(view v), following:
windowmanager wm = (windowmanager)getapplicationcontext().getsystemservice(context.window_service); wm.removeview(v);
however, when tap on ok, fatal exception "java.lang.illegalstateexception: not execute method of activity" , "java.lang.illegalargumentexception: view not attached window manager"
how can remove system overlay activity?
Comments
Post a Comment