Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

full screen application android

i have two questions:

  1. one how can i run my application in full screen
  2. how video players run videos in full screen.

i have tried alot and still struggling to achieve this but couldn't find a solution.

the list of solution i found but they are not fulfilling my requirements

  • this hides only the notification bar.

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    

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

  • also hides only the notification bar

    android:label="@string/app_name"
    android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
    
  • it low profiles the navigation bar not hiding it.

    getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);

  • no effect on my activity.

    anyView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);

note that:

  • i am not talking about rooting a device,so please provide those solutions which can work without rooting a device.
  • i am not talking about hiding only notification bar,but full screen by hiding both navigation bar and notification bar too.
  • i am talking about jelly beans api 4.1 or greater than 4.1 version of android
  • and please give answers with code.

after my research and your answers, i am getting this:

enter image description here

but my app should look like this without navigation bar:

enter image description here

i do not want the system navigation bar visible in my app.

like image 211
Hamad Avatar asked Aug 29 '13 13:08

Hamad


People also ask

How do I force an application to full screen?

The easiest way to go full screen in an application or a game is to use the Alt + Enter keyboard shortcut. This method works for most games and apps unless they use it to enable other features.

What is fullscreen application?

Full screen mode allows you to watch videos that take up your entire screen. Android ComputeriPhone & iPad. More.


2 Answers

I'm not sure what you're after, but the following hides the Notification bar, and the Soft Navigation keys (as seen on Google Nexus-devices), so the app essentially is "full screen".

Edit2

In Android 4.4 (API 19) Google introduced the new Immersive mode which can hide the status & navbar and allow for a truly fullscreen UI.

// This snippet hides the system bars.
private void hideSystemUI() {
    // Set the IMMERSIVE flag.
    // Set the content to appear under the system bars so that the content
    // doesn't resize when the system bars hide and show.
    mDecorView.setSystemUiVisibility(
                View.SYSTEM_UI_FLAG_LAYOUT_STABLE
              | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
              | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
              | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
              | View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
              | View.SYSTEM_UI_FLAG_IMMERSIVE);
}

// This snippet shows the system bars. It does this by removing all the flags
// except for the ones that make the content appear under the system bars.
private void showSystemUI() {
    mDecorView.setSystemUiVisibility(
               View.SYSTEM_UI_FLAG_LAYOUT_STABLE
             | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
             | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}

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

Edit:
Tested on Android 4.3 (API 18) and Android 4.1 (API 16) with Soft Nav keys.

@Override
protected void onCreate(Bundle b) {
    super.onCreate(b);

    setContentView(R.layout.main);

    int mUIFlag = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                | View.SYSTEM_UI_FLAG_LOW_PROFILE
                | View.SYSTEM_UI_FLAG_FULLSCREEN
                | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;

    getWindow().getDecorView().setSystemUiVisibility(mUIFlag);
}

For more information read up on http://developer.android.com/reference/android/view/View.html#setSystemUiVisibility(int)

like image 191
kaderud Avatar answered Sep 25 '22 16:09

kaderud


-To hide Status bar:

A great solution I found for that issue, setting each Activity theme & windowSoftInputMode to the following values :

<activity   android:name=".MyActivity"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" 
            android:windowSoftInputMode="adjustResize">  <!-- theme : to set the activity to a full screen mode without a status bar(like in some games) -->
</activity>                                              <!-- windowSoftInputMode : to resize the activity so that it fits the condition of displaying a softkeyboard -->

for more info refer here.

-To hide Notification bar:

There are Two ways :

1- root your device, then open the device in adb window command, and then run the following:

 adb shell >
 su >
 pm disable com.android.systemui >

and to get it back just do the same but change disable to enable.

2- add the following line to the end of your device's build.prop file :

qemu.hw.mainkeys = 1

then to get it back just remove it.

and if you don't know how to edit build.prop file:

  • download EsExplorer on your device and search for build.prop then change it's permissions to read and write, finally add the line.
  • download a specialized build.prop editor app like build.propEditor.
  • or refer to that link.
like image 22
Muhammed Refaat Avatar answered Sep 22 '22 16:09

Muhammed Refaat