Java Android Status bar won’t stay hidden

The problem is:

I can hide the status bar of the android device, but it won’t stay hidden. Whenever I use a popup (AlertDialog) or an EditText input field the status bar pops back up and won’t disappear anymore.

Here is the code in the manifest.xml:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.skipbo"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="17"
    android:targetSdkVersion="21" />

<uses-permission android:name="android.permission.INTERNET" >
</uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" >
</uses-permission>

<application
    android:allowBackup="true"
    android:debuggable="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@android:style/Theme.Holo.NoActionBar.Fullscreen" >
    <activity
        android:name="com.skipbo.menus.MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />
</application>

And I have some code to enable Immersive mode in the main activity:

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    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);

Some additional info: The app is a game that runs in a single Activity. I had this problem earlier, but then I fixed it. Some while later (I guess I have changed something in the manifest) it didn’t work anymore. While I had it working, the EditText was transparent, but now it is white.

I hope this is enough info.

Greeting Boschma

Answer

Try this line ,

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);

Leave a Reply

Your email address will not be published. Required fields are marked *