Search Unity

Hide Android Status Bar

Discussion in 'Android' started by konsum490, Oct 1, 2012.

  1. konsum490

    konsum490

    Joined:
    Oct 1, 2012
    Posts:
    6
    Hi Everyone,

    I’m developing for android (Samsung tab 10.1) with unity 3d v. 3.5.1, a fantastic experience so far.
    However I want to hide the status bar (attatchment 1)

    I found an option called “status bar hidden”(attatchment 2). If I tick this box the status bar does not disappear as expected but stays in place and does not respond on touch anymore. However, tapping it fast and frequently can eventually close the app.

    How can I not only deactivate but hide the status bar? I’ve seen it working on other projects (the Gravity Project to name an example).

    Thank you for helping
     

    Attached Files:

    • $1.jpg
      $1.jpg
      File size:
      41.2 KB
      Views:
      12,329
    • $2.jpg
      $2.jpg
      File size:
      40.7 KB
      Views:
      13,249
  2. znoey

    znoey

    Joined:
    Oct 27, 2011
    Posts:
    174
    Hey konsum490,

    Sadly that isn't the status bar, although i forgot exactly what it is called.
    The status bar is shown at the top of the screen on most phones but doesn't contain the home, back, menu or other soft keys on it.
     
  3. Raigex

    Raigex

    Joined:
    Jul 6, 2012
    Posts:
    154
    That bar is basically the tablet equivilent of the touch keys you have on a phone (home, back, menu, and search). If you took it away then the person has no real way to leave your app, unless you provide one yourself.
     
  4. konsum490

    konsum490

    Joined:
    Oct 1, 2012
    Posts:
    6
    Thats exactely what I want to do.

    How can I remove the "touch-key-bar" and provide my own exit button?

    My java script skills are limited but I hope someone can give me an indication on how to do that.
     
  5. Raigex

    Raigex

    Joined:
    Jul 6, 2012
    Posts:
    154
    That's the thing. The OS will stop you from removing it. It does not allow your own exit buttons (except maybe finish()) because they cannot be sure if you will provide one. It is just like the thing where you cannot override the Home button with your own code.
     
  6. konsum490

    konsum490

    Joined:
    Oct 1, 2012
    Posts:
    6
    thank you for your responds guy's :)

    it is deffinetly possible with unity, check out the games that are out there made by unity3d . I've tested some on my device und the bar vanishes... unfortunatly I don't know how to aproach that isseue.
     
  7. miksumortti

    miksumortti

    Joined:
    Apr 7, 2012
    Posts:
    204
    You can't remove the bar without root command, but you can change it to "low profile mode" (=black with dim dots)

    This will make it to low profile mode (needs to be called with native Java plugin, but there could be other ways also)
    Code (csharp):
    1. View sb = getWindow().getDecorView();
    2. sb.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
     
  8. bpritchard

    bpritchard

    Joined:
    Jan 29, 2009
    Posts:
    444
    @miksumortti

    would you happen to have an example of how that java plugin would be crafted?
     
  9. miksumortti

    miksumortti

    Joined:
    Apr 7, 2012
    Posts:
    204
    Here is Unity documentation about plugins: http://docs.unity3d.com/Documentation/Manual/PluginsForAndroid.html
    You can also find porbably some tutorials by Googling.

    At short it is made like this (not complete steps though)
    -Create empty Android project in Eclipse
    -Add the Unity Androidplayer classes.jar to your Eclipse project's classpath
    -Add the code I posted to your project in an Activity for example to an function called "hide"
    -Export the project as .jar (select only the src folder)
    -Add the .jar to your Unity project to Assets/Plugins/Android folder
    -Call the function "hide" with an C# script in Unity when you want to make the bar low profile mode.
    -Edit the Android Manifest.xml appropriately and put it to Assets/Plugins/Android

    (All other plugin things are done the same way, and there are other ways of doing this also...)

    The Unity page explains it better, and some tutorials maybe too.
    If you are doing it first time, it can be a bit tricky but once you get the idea you can make the plugin things easily.
     
  10. konsum490

    konsum490

    Joined:
    Oct 1, 2012
    Posts:
    6
    @miksumortti: thank you for the effort :) but are you sure there is not a more consequent solution

    The issue is that I need a fool proof solution - for both, me and my users. The app I am working on will be given out to old people at ha hospital and I have to make sure they don’t quit the app accidently by pressing on the status bar buttons. On the other hand I am not a programmer and not skilled enough to do much more than implementing and modifying scripts in unity.

    I know that this is not the most fun circumstances to discuss such a topic, but I can’t help it and would be very grateful for every hint that helps me to get this working.
     
  11. miksumortti

    miksumortti

    Joined:
    Apr 7, 2012
    Posts:
    204
    If you need to completely remove the status bar, only option is to root the device and then make the application stop the SystemUI application of the device with some su script. I don't know how to stop the SystemUI app and get it stay stopped, but it's the same way how the status bar hider apps work.
     
  12. konsum490

    konsum490

    Joined:
    Oct 1, 2012
    Posts:
    6
    I don't need to remove it.

    Deactivating or overlaying it would be good enough as well!
     
  13. miksumortti

    miksumortti

    Joined:
    Apr 7, 2012
    Posts:
    204
    I think it's impossible to deactivate or overlay the buttons on it without rooting the device and using some hacky way to block the touches for the buttons or something.
     
  14. DMTSource

    DMTSource

    Joined:
    Jul 11, 2013
    Posts:
    36
    I think you are confusing fullscreen mode on other devices with fullscreen mode on the particular device you are developing for. That tablet has the soft keys combined with part of the action/title bar since its a landscape device. Other devices, like the nexus 7 or 10, have separate soft keys at the bottom which can be deactivated(that just means they become lil spots but the bar is still there) and the TOP action/title bar is removed fully. This is the kind of problems developers face on android since each manufacturer can create their own flavor of the Android operating system. I suggest testing on stock Android to avoid these device specific problems in the beginning of development, or they will drive you mad.

    You will not be able to accomplish what you want because the tablet needs the softkeys to work at all. Even if you managed to find a solution it would probably void the developer agreement in some way since it breaks the OS and navigation for the user.
     
    Last edited: Aug 12, 2013
  15. DudeOfAwesomer

    DudeOfAwesomer

    Joined:
    Oct 2, 2013
    Posts:
    1
    Just to update this, with Android 4.4 Kitkat, it is now natively possible to hide the navigation bar via the SYSTEM_UI_FLAG_IMMERSIVE_STICKY.

    This can be done with this code:

    Code (csharp):
    1. @Override
    2. public void onWindowFocusChanged(boolean hasFocus) {
    3.         super.onWindowFocusChanged(hasFocus);
    4.     if (hasFocus) {
    5.         decorView.setSystemUiVisibility(
    6.                 View.SYSTEM_UI_FLAG_LAYOUT_STABLE
    7.                 | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
    8.                 | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
    9.                 | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
    10.                 | View.SYSTEM_UI_FLAG_FULLSCREEN
    11.                 | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);}
    12. }
    which is detailed here: https://developer.android.com/training/system-ui/immersive.html
     
    Last edited: Apr 9, 2014
  16. totsboy

    totsboy

    Joined:
    Jul 12, 2013
    Posts:
    253
    Will it work on Unity 4.6?
    And where do I put this code?