Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android FullScreen Activity Programmatically

Tags:

android

I know that I can acheive that with:

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

I have a Settings Activity, where the user can set Fullscreen mode. When he comes back to the Main Activity, of course if he checked Fullscreen, the Activity must resume Fullscreen.

How to do this?

Thanks for help.

like image 504
Federico Ponzi Avatar asked Aug 15 '26 10:08

Federico Ponzi


1 Answers

As u are using this which must be used before setContentView(int). i think give a try ur getWindow().setFlags() in onResume() alternatively i am giving a link which might help u for ur case.U can set condition before setting or removing those.

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

You can use following link for your purpose which is doing the same for android 4.4 or below.Android 4.4 (API Level 19) introduces a new SYSTEM_UI_FLAG_IMMERSIVE flag for setSystemUiVisibility() that lets your app go truly "full screen. For lower ver as well link has some workaround by setting flags u can use.

  https://developer.android.com/samples/ImmersiveMode/src/com.example.android.immersivemode/ImmersiveModeFragment.html

for remove flags u also have clearFlag() which u added for purpose when needed.

like image 174
Manmohan Badaya Avatar answered Aug 16 '26 23:08

Manmohan Badaya



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!