How to prevent orientation switch

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

How to prevent orientation switch

Postby Superted » Wed Jul 08, 2009 11:34 am

Hi,

I've been searching for a way to prevent my application from switching to landscape mode. I'm building a game using the accelerometer, and it should just stay in portrait mode..
Does anybody know??

superted
Superted
Junior Developer
Junior Developer
 
Posts: 16
Joined: Sun Jun 14, 2009 12:46 pm
Location: The Netherlands

Top

Postby nmc » Wed Jul 08, 2009 6:47 pm

add
android:screenOrientation="portrait"

to your manifest.xml

(Google: "android manifest orientation")
nmc
Senior Developer
Senior Developer
 
Posts: 154
Joined: Thu Nov 27, 2008 8:30 pm
Location: Germany

Postby Superted » Wed Jul 08, 2009 10:46 pm

Thanks nmc.. sometimes I just can't find what I need.. thanks a lot
Superted
Junior Developer
Junior Developer
 
Posts: 16
Joined: Sun Jun 14, 2009 12:46 pm
Location: The Netherlands

Postby virtual » Thu Jul 16, 2009 11:49 am

Or in Activitie's onCreate(...) code

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); // for landscape

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); // for portrait

Enjoy.
Regards,
Virtual
virtual
Developer
Developer
 
Posts: 26
Joined: Tue Mar 24, 2009 11:20 am

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: Google Feedfetcher and 10 guests