Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent a hidden status bar from reappearing after screen lock

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?

like image 477
user1049280 Avatar asked Mar 14 '12 12:03

user1049280


People also ask

How can I hide my status bar only in Android?

Hide the Status Bar on Android 4.View decorView = getWindow(). getDecorView(); // Hide the status bar. // status bar is hidden, so hide that too if necessary.

How do I get rid of status bar on Samsung?

If you have a stock Android phone, you can remove the notification bar using System UI Tuner. For all other Android models, you can do this using a third-party app. In order for this to work, you must grant the app write secure settings permissions.


3 Answers

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);
    }
}
like image 130
Jake Wilson Avatar answered Oct 31 '22 19:10

Jake Wilson


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();
    }
}
like image 1
Alexander Avatar answered Oct 31 '22 18:10

Alexander


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>
like image 1
Holtrod Avatar answered Oct 31 '22 18:10

Holtrod