17

I have seen certain apps, especially most of the games (Eg. Angry Birds, Temple Run etc) run fullscreen and in landscape mode when launched. Their orientation never changes and they never exit fullscreen when the screen is touched. How its done? What properties do I need to change or code?

asgoth
  • 35,552
  • 12
  • 89
  • 98
Sunit Prasad
  • 323
  • 1
  • 2
  • 6
  • 2
    sorry, but it is to common question, just use google and android developer site: http://developer.android.com/develop/index.html; http://www.google.com/ – sebap123 Jan 06 '13 at 13:02
  • I have Googled it but in vain. In the Android Developers website, I couldn't figure it out despite going through all the properties etc. – Sunit Prasad Jan 06 '13 at 13:04
  • 3
    Yet another example of how pathetic "SO fundamentalism" can be. You could say "Use Google" to a massive number of SO questions, many of them with tens or hundreds of votes. Nobody seems to complain about them. – async Mar 28 '14 at 23:01
  • Two quick Google searches revealed the answers to your questions. Force fullscreen on an activity: http://www.androidsnippets.com/how-to-make-an-activity-fullscreen Force orientation on an activity: https://stackoverflow.com/questions/2150287/force-an-android-activity-to-always-use-landscape-mode – Niklas Ekman Jan 06 '13 at 13:03

4 Answers4

21

If you prefer to use XML, you can change the AndroidManifest.xml:

<activity android:name="..."
    android:screenOrientation="landscape"
    android:theme="@android:style/Theme.NoTitleBar.Fullscreen">

</activity>

If you are targetting Android SDK 9 or above, you can use sensorLandscape instead of landscape which will mean that the screen will look the correct way up on both normal landscape orientation and reverse landscape orientation.

Dolanor
  • 822
  • 9
  • 19
Tom Leese
  • 19,309
  • 12
  • 45
  • 70
9
import android.view.Window;
import android.view.WindowManager;
import android.content.pm.ActivityInfo;

@Override public void onCreate(Bundle savedInstanceState)
{
    ...

    // Set window fullscreen and remove title bar, and force landscape orientation
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

    ...
}

Solution to your problem

siranen
  • 374
  • 1
  • 11
4

The problem is solved, and based on the answers given above, what I did was,

Step 1 : In the manifest.xml file,

<application
. . .
android:screenOrientation="landscape"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
. . .
</application>

Step 2 : In the Java file, I made the following changes,

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
   }

and now my app runs fullscreen, landscape without any issues. Thank You all.

Sunit Prasad
  • 323
  • 1
  • 2
  • 6
1

Put this in onCreate() in every activity class (screens):

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

This code will disable android notification bar ( pull up to down ). !!!

Grzegorz Sławecki
  • 1,727
  • 14
  • 27
rares
  • 61
  • 1
  • 2