disabling and hiding android navigation bar/notification menu permanently

后端 未结 3 1976
渐次进展
渐次进展 2021-01-20 15:24

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 insid

相关标签:
3条回答
  • 2021-01-20 15:57

    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.

    0 讨论(0)
  • 2021-01-20 16:01

    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.

    0 讨论(0)
  • 2021-01-20 16:19

    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.

    0 讨论(0)
提交回复
热议问题