Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am beginner in android game development. I want my game to run only in landscape fullscreen mode (currently I have Optimus 2X with resolution 800x480 in landscape), and I don't know how to set it.

I found the fullscreen mode settings, and tried some landscape mod (set orientation:landscape in AndroidManifest), but the game is now crashing and its very unstable (eg. when i change phone orientation).

So is there any way to do that?

share|improve this question
Code does help. – The Communist Duck Jul 1 '11 at 11:06
What part of my code should I post? My problem is how to set landscape in simple android app, because I cant find anythink in android development docs. – davidv Jul 1 '11 at 11:18
Post your LogCat error message. – Wroclai Jul 2 '11 at 16:52
up vote 2 down vote accepted

I'm currently working on a full-screen Android game that runs exclusively in landscape mode. Here are the tweaks I've made to force landscape mode and prevent application restarts:

Intercept orientation change events

Add the following android:configChanges to your AndroidManifest.xml

<activity android:name=".FirstGame"

Override onConfigurationChanged in your Activity to prevent application restart

public void onConfigurationChanged(final Configuration newConfig)
    // Ignore orientation change to keep activity from restarting

Forcing full-screen landscape orientation

In the onCreate function of your Activity, add the following code to set window fullscreen and remove title bar, and force landscape orientation

import android.view.Window;
import android.view.WindowManager;

@Override public void onCreate(Bundle savedInstanceState)

    // Set window fullscreen and remove title bar, and force landscape orientation
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

share|improve this answer

If you have more than one activity that you are using, you are going to need to set the orientation for all of them to landscape, if you have one as landscape and another as portrait. When you switch over to the other activity it will crash unless you have it set up properly to do that. If I knew how to post the code from my manifest to where it shows up I would.

The link explains if you want to switch between orientations.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.