2

I am building a new lock screen for Android, but I am unable to lock the notification bar from pulling it down.

I want to disable the notification bar pull-down.

InnocentKiller
  • 5,234
  • 7
  • 36
  • 84
user3442136
  • 21
  • 1
  • 1
  • 2

3 Answers3

6
    private void disablePullNotificationTouch() {
            WindowManager manager = ((WindowManager) getApplicationContext()
                    .getSystemService(Context.WINDOW_SERVICE));
            WindowManager.LayoutParams localLayoutParams = new WindowManager.LayoutParams();
            localLayoutParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_ERROR;
            localLayoutParams.gravity = Gravity.TOP;
            localLayoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
                    // this is to enable the notification to recieve touch events
                    WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |
                    // Draws over status bar
                    WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;

            localLayoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
            localLayoutParams.height = (int) (25 * getResources()
                    .getDisplayMetrics().scaledDensity);
            localLayoutParams.format = PixelFormat.RGBX_8888;
            customViewGroup view = new customViewGroup(this);
            manager.addView(view, localLayoutParams);
        }

//Add this class in your project
public class customViewGroup extends ViewGroup {

    public customViewGroup(Context context) {
        super(context);
    }

    @Override
    protected void onLayout(boolean changed, int l, int t, int r, int b) {
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {

        Log.v("customViewGroup", "**********Intercepted");
        return true;
    }

}
NitinM
  • 303
  • 4
  • 12
1

Unless you modify system SystemUI.apk file, it's not possible, even then your app will require root permissions. The best you could do is create an app in fullscreen mode which will hide notification bar.

arleitiss
  • 107
  • 2
  • 13
0

Firstly, you need the EXPAND_STATUS_BAR permission:

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

and hope this link will help you for sure..

Community
  • 1
  • 1
Akshay
  • 6,029
  • 7
  • 40
  • 59
  • I have already done that one. In that we can click the notification in between the bar collapses. I need that there should be no access to the notification bar when the screen is locked. – user3442136 Mar 24 '14 at 08:06
  • Please see my answer above – NitinM Dec 15 '16 at 20:25