Ex-Ex
Ex-Ex

Reputation: 176

disabling and hiding android navigation bar/notification menu permanently

Im developing an android application for a school and i want this application when opened to prevent the user from doing anything on the device except what im offering inside my application, and i mean doing NOTHING else... so first the Navigation bar should be disabled and hided

i saw this but its for 4.4+ and it doesn't solve the problem because if you swipe the screen you will get the menu back. (How to hide navigation bar permanently in android activity?)

this doesn't work also(Permanently hide navigation bar on activity) (Is there a way to hide the system/navigation bar in Android ICS) i also tried to disable navigation bar actions using onKeyDown but it didn't work on all of the keys.

in addition i want to remove the notification bar which make the user access the settings of the device and other things..

and this not working also (Disable the notification panel from being pulled down) as mentioned in this link it doesn't solve it, it just hides it after showing it :S

help would be appreciated,

Thanks.

Upvotes: 3

Views: 7366

Answers (3)

tagy22
tagy22

Reputation: 1360

You can get a kiosk type mode in Android 5.0, using the screen pinning feature mentioned here:

Android 5.0 introduces a new screen pinning API that lets you temporarily restrict users from leaving your task or being interrupted by notifications. This could be used, for example, if you are developing an education app to support high stakes assessment requirements on Android, or a single-purpose or kiosk application. Once your app activates screen pinning, users cannot see notifications, access other apps, or return to the home screen, until your app exits the mode.

You can lock the device down to be a kiosk. The navigation bar is not hidden, but the home and recents buttons can be removed or disabled depending how you activate the mode. I wrote some information after testing this feature here.

Upvotes: 4

amalBit
amalBit

Reputation: 12181

Its possible

To disable the Status NotificationBar:

You need to place a view on top of the notification bar, so that we hijack the touch events to the Status notification bar. Without further ado, here is the code:

mView= new TextView(this);                                       
mView.setText(".........................................................................");                       

mLP = new WindowManager.LayoutParams(
        WindowManager.LayoutParams.MATCH_PARENT,
        100,
        // Allows the view to be on top of the StatusBar
        WindowManager.LayoutParams.TYPE_SYSTEM_ERROR,
        // Keeps the button presses from going to the background window
        WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
        // Enables the notification to recieve touch events
        WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |
        // Draws over status bar
        WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN,
        PixelFormat.TRANSLUCENT);

mLP.gravity =  Gravity.TOP|Gravity.CENTER;      

mWindowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
mWindowManager.addView(mView, mLP);

And since you are using the system overlay window, you need the permission:

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

Note:

Do not make your app full screen, as the versions above 17, which supports immersive mode, will screw this approach.

Upvotes: 2

Booger
Booger

Reputation: 18725

You can NOT disable the system or notification panel in Android.

You can hide these elements (like you have already discovered), but currently, you can NOT disable them permanently.

You are looking for a 'Kiosk Mode' which is not supported.

The closest thing to what you are looking for is 'Immersive Mode' (details) - but this does NOT hide the settings or navigation controls permanently.

Upvotes: 1

Related Questions