2

I am using these lines to get full screen, but the bar for Battery and Antenna is still there.

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

I even checked a line mentioned in How to get rid of top fading edge in android full screen mode? When I add that (setTheme(android.R.style.Theme_NoTitleBar_Fullscreen);), screen goes up, but it's kinda like the bar is on top of my screen. I naturally assume that the OS (Android 4.0.4) does not allow that, but I was said that this code will force it to be like that, nevertheless it's not working, the final code to be more precise is this:

public void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setTheme(android.R.style.Theme_NoTitleBar_Fullscreen);
        getWindow().setFlags(
                WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
        setListAdapter(new ArrayAdapter<String>(Menu.this,
                android.R.layout.simple_list_item_1, classes));
    }

Would you please help me here?

Community
  • 1
  • 1
Yousef
  • 393
  • 8
  • 23

5 Answers5

2

To show app in fullscreen use:

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

To remove it use:

getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
Strider
  • 4,452
  • 3
  • 24
  • 35
2

you are doing every thing right the code is simple for getting the full screen

requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    //if you want it too other vice first one is good enough
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
            WindowManager.LayoutParams.FLAG_FULLSCREEN | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

**

Note please add it before setContentView

**

ghost talker
  • 402
  • 5
  • 15
  • @ghosttalker why did you put `FLAG_KEEP_SCREEN_ON` in your code? it has nothing to do with his question – Strider Jun 17 '15 at 13:55
1

EDIT: Seems like you have everything right except you have the flag FLAG_FORCE_NOT_FULLSCREEN twice

First, make sure your theme does not include an actionbar. Then, add the following in onCreate:

getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
mray190
  • 496
  • 3
  • 13
  • It was twice in every code I've seen, here too, from others. I don't know why though. – Yousef Jun 17 '15 at 13:51
  • Once is to clear the flag of the non-fullscreen mode. Then the other is to add the full screen mode flag. – mray190 Jun 17 '15 at 13:55
1

for Full Screen of Activity You should have to use below code before super.onCreate(savedInstanceState);

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

or If you are using Theme.AppCompat in your application you can use FullScreenTheme by adding below style in style.xml

<style name="Theme.AppCompat.Light.NoActionBar.FullScreen" 
 parent="@style/Theme.AppCompat.Light">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">@null</item>
</style>

and also mention in your manifest file

    <activity
      android:name=".activities.FullViewActivity"
      android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen" 
     />
0

This is what you are looking for:

https://developer.android.com/training/system-ui/immersive.html

Also, i attach you a related question:

Using new IMMERSIVE mode in android kitkat

Community
  • 1
  • 1
iGio90
  • 3,251
  • 7
  • 30
  • 43