Kostadin Kostadin - 4 months ago 22x
Android Question

Screen orientation and values in manifest.xml

I want to use all activities in my form in landscape or portrait.
When user select orientation - this is valid for all activities.
Tried with "behind" option orientation. According to Google - orientation will depend on previous activity.
My first activity use setRequestedOrientation to set selected from user orientation.
Next activities have to follow same orientation.
Do I have to put setRequestedOrientation in their code too? Or relly on 'behind' parameter in manifet? Putting setRequestedOrientation may be cause onCreate again?

Tried "portrait" and setRequestedOrientation() - resilt si onCreate was called 2 times.
Problem is in next activity -> because of "portrait" in first activity - android started next activity with same orientation. It ignores "landscape" orientation wich was set by me :(


For now I put check in onCreate:

m_bSkip = (this.getRequestedOrientation() != MyApp.sInstance.GetScreenOrientation());
if (m_bSkip)

When I enter oncreate and screen orientation is not desired - exit. When I enter in onCreate and screen orientation is desired one - continue with initialization. This fixes situation without need of keeping async task related to activity and check for new activity. Of course all functions: onStart,onResume,onPausde,onStop... have to check this flag to avoid null pointer exception.