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

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -