hiding the navigation bar in Android

edited November 2014 in Android Mode

Hi,

I'm trying to hide the navigation bar when my app is running in Processing for Android. What I mean is the Back, Home and App Switcher icons that appears at the bottom of the Android device. I have tried several methods found on the web but none have worked. Running on latest android 4.4.2.

Any suggestions will be greatly appreciated.

Answers

  • Have you read the Android Developers lesson about this? If this is what you have tried, then please define "none have worked" more concretely. You probably need to import some of the native Android classes and place the code in onCreate().

  • edited August 2014

    I have tried this code found in the old Processing forum, it will crash when the app tries to launch.

    @ Override
    public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      requestWindowFeature(Window.FEATURE_NO_TITLE);
    }
    

    I am not sure how to implement the example given by Google into my Processing for Android app: https://developer.android.com/training/system-ui/immersive.html

    If there's a working example of hiding the navigation in Android for Processing, it will be very helpful.

  • I have been digging into this and it appears that API 11+ is required; I have not been able to successfully import the compatibility library v7. Anybody had luck with this? It would be very nice to use full screen mode.

  • Answer ✓

    --- it s rather simple to hide/show the action bar with P5 --- its (for the moment) impossible (i think!) to hide the navigation bar because immersive sticky mode requires KitKat (API 19) at least. Using the code below shows that; also looking at the very beginning of the compiler message in the console ("Project Target: Android 2.3.3 API level: 10 WARNING: Attribute minSdkVersion in AndroidManifest.xml (19) is higher than the project target API level (10))

    the code:

        import android.view.WindowManager;
        import android.view.View;
        import android.view.Window;
        import android.os.Bundle;
    
    
        protected Window window;
        boolean apiTooOld = true;
    
        void setup(){
        orientation(PORTRAIT);
    
    
        }
    
        void draw(){
          background(0);
          textSize(24);
          fill(255);
          text("trying to hide NavigationBar", 200,200);
        }
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
    
        //if (Build.VERSION.SDK_INT < 19){ // this useful! method is working in eclipse android but not for processing because the Build Project is hardcoded to API 10
         //apiTooOld = false;// try uncommenting...
         ///}
    
         /// i think that you have to get the jar and change the hardcoded values but i am not at all sure that changing these values does not create other problems...
    
          if (apiTooOld){
        Window window = getWindow();
            // you can also do that with the manifest xml
            window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                           WindowManager.LayoutParams.FLAG_FULLSCREEN);
    
            }
        }
        //// if you compile with API 19 or more this could work but you cannot test with processing so i comment out
        //@Override
        //public void onWindowFocusChanged(boolean hasFocus) {
        //    super.onWindowFocusChanged(hasFocus);
        //    
        //    if (hasFocus && !apiTooOld ) {
        //        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_STICKY
        //            );}// this is the code from android "immersive mode"
        //}
    
  • hi akenaton, thanks for your post, I just tested your code, but it did not work. I'm using eclipse to compile and testing on Nexus 4 (phone) and 7 (tablet).

    Is your code tested?

  • Tested with processing and sonyXperia Z: hiding the action bar runs; but of course (see my post) hiding the navigation bar does not run. Tested with eclipse, build project 20, minSdk19, same device but in native android code... Are you using eclipse + processing? - if true i think that the code will not run, for the same reasons. You can look to the java code source for android processing: build project is hard coded for 2.3 gingerbread....

  • edited March 2016

    Hi there

    I don't know if it is relevant to post my question here, considering the dates of the topic, but lets try

    Using the code I found here, I get the immersive mode working with both the action bar and the navigation bar hiding properly

    Now the problem is that my Processing canvas is not really full-screen, the space being left void by the navigation bar moving away is left blank

    Any Idea on how to take the whole screen ? Or is it impossible due to the fact that Processing is stuck to gingerbread ?

    EDIT: I got it to work : ]

    In the activity_main xml, I did switch android:fitsSystemWindows to "false"

    And now when I run my app, the sketch is really fullscreen

Sign In or Register to comment.