views:

149

answers:

6

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?

+2  A: 

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

Andy Zhang
I tried, again the same problem :(
A: 

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.

Julian Assange
A: 

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

android:screenOrientation="landscape"

and not "portrait" :P

Rodrigo Cavalcanti
+1  A: 

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

Hamy
Mind you, HTC Hero is still 'stuck' on 1.5 IIRC...
Eno
Yes you are right, I tested with many apps
@Eno - negative, I am running 2.1 that I received OTA. I am using Sprint's version of the HTC Hero, not the typical HTC Hero
Hamy
That's good to hear. So, another 6 months before you get 2.2? :-)
Eno
+1  A: 

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.

Brad Hein
A: 

Thanks to all , but it seems this is a "problem" that can't be resolved . Thanks again for trying to help :)