3

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.

Community
  • 1
  • 1
Hamzeh
  • 167
  • 1
  • 4
  • 13

3 Answers3

4

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.

Community
  • 1
  • 1
tagy22
  • 1,353
  • 17
  • 26
2

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.

amalBit
  • 12,041
  • 6
  • 77
  • 94
  • the app crashed,and it worked when i added but its not disabling the notification Bar – Hamzeh Aug 25 '14 at 10:13
  • Try to increase the Height param. Replace 100 with a bigger value. It worked for me. – amalBit Aug 25 '14 at 11:57
  • I added the permission but App is still crashing with error message: "Caused by: android.view.WindowManager$BadTokenException: Unable to add window android.view.ViewRootImpl$W@a969c7 -- permission denied for this window type" OS Version 6.0.1 Device: Nexus 5 – Ahmad Shahwaiz Nov 03 '16 at 13:19
  • @AhmadShahwaiz Now there are device owner permissions, using that will give u access to APIs that can disable the statusbar without any hacks. (OS 6 and above) – amalBit Nov 04 '16 at 15:22
1

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.

Booger
  • 18,579
  • 7
  • 55
  • 72
  • yes but hiding is also not working here, because on a single touch on the screen the navigation menu goes back. – Hamzeh Aug 24 '14 at 12:38
  • That is how it is SUPPOSED to work. Android doesn't want you to permanently hide the system elements, so ensures you can access them easily. – Booger Aug 24 '14 at 12:56
  • This is completely stupid and renders the system even less suitable for fast paced games! Imagine playing - for example - Dota2 and continuously popping up some annoying menu by accidentally clicking on the top area of the screen... Android, I will whack your tin head one day, I swear! ...sorry guys. Thanks for this answer though, saved me a lot of time looking for the impossible. – ElDoRado1239 Jan 05 '15 at 07:32