Prevent reappearance of hidden status bar after screen lock

I want to hide the 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, a status bar will appear, how to solve this problem?

+6
source share
4 answers

To hide the Android status bar and 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 putting this code in your appropriate activity after returning from the lock screen:

 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); } } 
+1
source

If security is not a problem, you can turn off the lock screen while your application is running. Add the following line to the manifest:

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

In your activity you can do the following:

 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(); } } 
+1
source

use this code in onCreate() to setContentView()

 this.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); 
0
source

Write this code in your aapplication mainfest.xml file in the application tag, as shown below:

 <application android:name="application package" android:label="application name" android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"> 
-2
source

Source: https://habr.com/ru/post/910700/


All Articles