statusbar - Android disable status bar interaction -


is there way, on android keep status bar while disabling interaction can it, pulling down? want keep information bar gives, don't want users interact it.

this method use. can unwrap method , place inside base activity instead. iirc, got stackoverflow well, didn't make note of i'm not sure original post is.

what place transparent overlay on top bar intercepts touch events. it's worked fine me far, see how works you.

you may need put line in androidmanifest:

<uses-permission android:name="android.permission.system_alert_window" /> 

i have in project, can't remember if it's because of or else. if permission error, add in.

windowmanager manager; customviewgroup lockview;  public void lock(activity activity) {      //lock top notification bar     manager = ((windowmanager) activity.getapplicationcontext()             .getsystemservice(context.window_service));      windowmanager.layoutparams topblockparams = new windowmanager.layoutparams();     topblockparams.type = windowmanager.layoutparams.type_system_error;     topblockparams.gravity = gravity.top;     topblockparams.flags = windowmanager.layoutparams.flag_not_focusable|             // enable notification recieve touch events             windowmanager.layoutparams.flag_not_touch_modal |             // draws on status bar             windowmanager.layoutparams.flag_layout_in_screen;     topblockparams.width = windowmanager.layoutparams.match_parent;     topblockparams.height = (int) (50 * activity.getresources()             .getdisplaymetrics().scaleddensity);     topblockparams.format = pixelformat.transparent;      lockview = new customviewgroup(activity);     manager.addview(lockview, topblockparams); } 

and customviewgroup is

private class customviewgroup extends viewgroup {     context context;      public customviewgroup(context context) {         super(context);         this.context = context;     }      @override     protected void onlayout(boolean changed, int l, int t, int r, int b) {     }     @override     public boolean onintercepttouchevent(motionevent ev) {         log.i("statusbarblocker", "intercepted "+ this.tostring());         return true;     } } 

also! have remove view when activity ends, because think continue block screen after kill application. always, always call onpause , ondestroy.

    if (lockview!=null) {         if (lockview.isshown()) {             //unlock top             manager.removeview(lockview);         }     } 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -