Prevent a hidden status bar from reappearing after screen lock
Asked Answered
B

5

7

i want to hide status bar in my application to make it fullscreen, so i use this example Hide Notification bar - it works fine. But if i lock the screen and then unlock it, the status bar appears, how to solve this problem?

Beetlebrowed answered 14/3, 2012 at 12:30 Comment(4)
Are you referring to the Android operating system status bar at the top of the screen? The one containing the battery life, time, Wifi signal, etc?Urba
Are you adding that theme attribute in activity tag? may be you should try in application tag, if u didnt that..Dudek
yea i've tried, it doesn't workBeetlebrowed
I have the same problem. Have you found an answer?Glassman
U
1

To hide the Android Status Bar and the Application Title bar, add the following to the Manifest file:

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

Example:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="de.vogella.android.temperature"
      android:versionCode="1"
      android:versionName="1.0">
    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".Convert"
                  android:label="@string/app_name"
                  android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    </application>
    <uses-sdk android:minSdkVersion="9" />

</manifest>

UPDATED

Also try to put this code in your relevant activity after returning from the lockscreen:

public class FullScreen extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
                                WindowManager.LayoutParams.FLAG_FULLSCREEN);

        setContentView(R.layout.main);
    }
}
Urba answered 14/3, 2012 at 18:5 Comment(2)
i've already done that - it works only til i lock and unlock screenBeetlebrowed
Updated my answer, you might have more luck with that.Urba
E
1

If security is not an issue, you can disable the lock screen while your app is running. Add the following line to the manifest:

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

In your activity, you can do as follows:

public class MyActivity extends Activity {
    private KeyguardLock lock;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // Disable lock screen.
        KeyguardManager keyGuardManager = (KeyguardManager) getSystemService(KEYGUARD_SERVICE);
        lock = keyGuardManager.newKeyguardLock("MyActivity");
        lock.disableKeyguard();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        // Reenable the lock screen again.
        lock.reenableKeyguard();
    }
}
Ebracteate answered 13/7, 2012 at 10:15 Comment(0)
S
1

Only add this to the styles

 <style name="AppTheme" parent="Theme.Design.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="android:statusBarColor">@android:color/transparent</item>
    <item name="android:windowFullscreen">true</item>
</style>
Sunshine answered 8/5, 2018 at 18:37 Comment(0)
T
0

use this code in onCreate() before setContentView()

this.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
Terminate answered 5/8, 2012 at 12:0 Comment(0)
D
-2

Write this code in your aapplication's mainfest.xml file in application tag as below:

<application  android:name="application package"
            android:label="application name" android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"> 
Dudek answered 14/3, 2012 at 12:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.