user345602
user345602

Reputation: 598

Android orientation issue

I have application which works only in landscape orientation . I set that in xml layout. When I'm starting application it works ok . But when the application is started and next if I lock the phone and then unlock, the application first 1-2 seconds is in portrait mode and then in landscape. Is it possible to skip theese 2 seconds?

Upvotes: 4

Views: 774

Answers (5)

Brad Hein
Brad Hein

Reputation: 11047

Execute this in your onCreate(), just before setcontentview:

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

I use this method in my apps and I never notice the orientation changing. It's locked solid into the requested orientation.

Upvotes: 1

Curtain
Curtain

Reputation: 1972

I hope this help; put these on every activity-element in your Android Manifest-file.

android:configChanges="orientation"
android:screenOrientation="landscape"

Of course it is landscape; my brain was not the quickest this time.

Upvotes: 0

Hamy
Hamy

Reputation: 21552

Not to be a downer, I really hope you solve this. Just wanted to throw out there that I have noticed this sort of behavior(typically for me the apps are supposed to stay in portrait but they show landscape for about 2 seconds) on multiple applications on my Sprint HTC Hero, including the default home application and many of the default included apps (contacts, etc). I am beginning to suspect it's an android problem. Again, feel free to disagree with me, but I just wanted to say that I have noticed this on a lot of apps & you're not alone here :/ However, there are some apps that I have not noticed it on, so either a) I am just getting lucky or b) there is a correct solution

Upvotes: 1

Rodrigo Cavalcanti
Rodrigo Cavalcanti

Reputation: 71

To be provocative, actually, what he needs to put in each activity element in his manifest is:

android:screenOrientation="landscape"

and not "portrait" :P

Upvotes: 0

Andy Zhang
Andy Zhang

Reputation: 8315

Try defining it explicitly in your manifest. Add android:screenorientation="portrait" to each <activity> element.

Upvotes: 2

Related Questions