Easy way to hide system bar on Android ICS

后端 未结 8 1140
抹茶落季
抹茶落季 2020-11-28 10:32

I will give my ICS tablets for users to complete a survey so I would like the user to work with my app only. They should not be able to switch to the home screen, press back

相关标签:
8条回答
  • 2020-11-28 10:34

    After a lot of searching on the internet, I managed to get the System Bar to hide and appear in a 4.2 device using:

    To Hide:

    Runtime.getRuntime().exec("service call activity 42 s16 com.android.systemui");
    

    Or use 79 instead of 42 for API less than 14. You may also need to include the SET_DEBUG_APP permission, in which case you need to have the application signed with the system key or installed in the /system/app/ directory.

    To Show:

    Runtime.getRuntime().exec("am startservice --user 0 -n com.android.systemui/.SystemUIService");
    

    Alternatively some people have used the -a (instead of -n) option, though this was causing an error on my device:

    Error: Not found; no service started.

    For Android 4.4, there is a new feature called immersive mode which hides both the system and status bars. The system UI is toggled by the user through the use of an edge swipe from the top or bottom of the screen. For more details take a look at:

    http://developer.android.com/reference/android/view/View.html#setSystemUiVisibility(int)

    Using new IMMERSIVE mode in android kitkat

    For example:

    getWindow().getDecorView().setSystemUiVisibility(
              View.SYSTEM_UI_FLAG_LAYOUT_STABLE
            | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
            | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
            | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
            | View.SYSTEM_UI_FLAG_FULLSCREEN
            | View.SYSTEM_UI_FLAG_IMMERSIVE)
    
    0 讨论(0)
  • 2020-11-28 10:35

    Google intends Android to be used for consumers only. They integrated the System UI bar more tightly into Android ICS (4.0) to prevent people from rooting the device and killing the bar that way. Attempting to delete the system bar process will prevent the OS from booting fully.

    If you want to restrict users from accessing the home screen, then you are out of luck with Android ICS. I would suggest finding a tablet manufacture who will preload the device with Android 2.3. Either that, or use a rooted Android 3.x device.

    If you intend to use Android for kiosk or locked down devices, then you would be better off targeting an OS that is a bit more open.

    0 讨论(0)
  • 2020-11-28 10:38

    There is a workaround to disable menu bar (not hide) in all most all tablets without rooting. But this is bit tricky, but it works clean. Several well known apps in the market at the moment using this strategy to achieve this disable menu bar feature for their apps.

    • Grant admin privilege (need one time user involvement to activate).
    • Set password & lock the device using device admin profile api programatically.
    • Then load what ever the UIs on top of the native lock screen. (Of course this will show background lock screen whenever a transition happens between activities. But if logic is organized well, then it will be smooth & less noticed by the user)
    • When need to enable back, reset password to "" using resetPassword("", 0) of device policy manager object.
    0 讨论(0)
  • 2020-11-28 10:43

    check this link: (requires root) http://android.serverbox.ch/?p=306

    similar question was posted here also: Is there a way to hide the system bar in Android 3.0? It's an internal device and I'm managing navigation

    or try HideBar http://ppareit.github.com/HideBar/

    Actually you can simply put the system bar in "lights out" mode, the system bar buttons and notifications gets dimmed.

    View v = findViewById(R.id.view_id);
    v.setSystemUiVisibility(View.STATUS_BAR_HIDDEN);
    
    0 讨论(0)
  • 2020-11-28 10:46

    I want to add some information to the existing replies hoping it will be useful for someone.

    To get a real full screen working on my low cost China tablets I need to edit a file located in

    system/build.prop
    

    replace the text

    ro.property.tabletUI=true
    

    with

    #ro.property.tabletUI=true
    

    (I comment the line). After that, I can get a full screen using

    android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
    

    for each activity in the minfest.xml

    This solution Is good only if you sell tablets with your application and needs root privileges to edit the system/build.prop. So it's not a solution for all, so please do not downvote this little contribute.

    EDIT: I noticed that my tablets have hardware buttons (Home, menù and back) on the frames. So Android lets me to hide the system bar. I tryed with other tablets that haven't hardware buttons without success.

    0 讨论(0)
  • 2020-11-28 10:48

    HideBar has a kiosk mode especially for this use case.

    A free download is available at http://ppareit.github.com/HideBar/. You can also find it in the market at https://play.google.com/store/apps/details?id=be.ppareit.hidebar.

    If you want to incorporate it in your own test/survey application you can always contact the developer (see the links for an email). The code could be explained or an Intent to do the hiding could be provided.

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