Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Permanently hide Android Status Bar

I'm trying to hide the system Status Bar on an Android 4.4 device. This is for a kiosk-mode where my app will be the only app ever run on the device. The target device for now is a 2013 Nexus 7.

The device is rooted, and I've been able to completely remove the bottom Navigation Bar with some info from this post.

For the top Status Bar, everything I have tried only hides the bar temporarily. If my users motion down at the top of the screen, the status bar reappears. I don't want to allow them to see the time, get to settings or even see notifications.

Posts I've found and already tried:

  • Hide System Bar in Tablets
  • Permanently hide navigation bar on activity
  • Hide status bar on android
  • Disable/Hide status bar in Android

Any suggestions?

Ideally, I'd love to be able to edit build.prop to do this, since I'm already doing that for the navigation bar, and could do this at the same time. I'm trying to not have to build my own android image.

Update:

After some more work, this seems to depend somewhat on the exact build of android, or the device its running on.

Some devices, such as the Nexus series I've been working with allow the user to swipe to make the bar reappear.

However, I've recently tried this on a Verizon Eclipse, and the bar does not reappear, which is what I was looking for.

I'm still looking for a better solution to target all devices, but it will probably come down to creating my own build of android.

like image 844
dtyler Avatar asked Jan 27 '14 01:01

dtyler


People also ask

How do I get rid of status bar on Samsung?

Make sure your device is running Samsung One UI 2.0, 2.1, or later. Head to Settings > Notifications. Tap “Status bar”. Turn off the toggle button next to “Show notification icons”.

Which command is used to hide and display status bar?

View decorView = getWindow(). getDecorView(); // Hide the status bar.


1 Answers

We could not prevent the status appearing in full screen mode in kitkat devices, so made a hack which still suits the requirement ie block the status bar from expanding.

For that to work, the app was not made full screen. We put a overlay over status bar and consumed all input events. It prevented the status from expanding.

note:

  • customViewGroup is custom class which extends any layout(frame,relative layout etc) and consumes touch event.
  • to consume touch event override the onInterceptTouchEvent method of the view group and return true

Updated

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

customViewGroup implementation Code :

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) (50 * getResources()             .getDisplayMetrics().scaledDensity);     localLayoutParams.format = PixelFormat.TRANSPARENT;      customViewGroup view = new customViewGroup(this);      manager.addView(view, localLayoutParams); 

Hope this helps you

like image 103
Abhimaan Avatar answered Sep 26 '22 06:09

Abhimaan