Hi Guys ,
Is there a way to let Android OS handles the my Activity orientation automatically ? for instance if the screen orientation now is landscape so the Activity will be landscape and if it changed the activity changes too ..
From the Android SDK reference
"Unless you specify otherwise, a configuration change (such as a change in screen orientation, language, input devices, etc) will cause your current activity to be destroyed, going through the normal activity lifecycle process of onPause(), onStop(), and onDestroy() as appropriate. If the activity had been in the foreground or visible to the user, once onDestroy() is called in that instance then a new instance of the activity will be created, with whatever savedInstanceState the previous instance had generated from "
So, you can specify any orientation related task at onCreate() method of your activity itself.
Sumit Bisht wrote:From the Android SDK reference
"Unless you specify otherwise, a configuration change (such as a change in screen orientation, language, input devices, etc) will cause your current activity to be destroyed, going through the normal activity lifecycle process of onPause(), onStop(), and onDestroy() as appropriate. If the activity had been in the foreground or visible to the user, once onDestroy() is called in that instance then a new instance of the activity will be created, with whatever savedInstanceState the previous instance had generated from "
So, you can specify any orientation related task at onCreate() method of your activity itself.
i found this too, but when i tried it always go to landscape mode!! see the attachments,
I posted on Stack Over flow too about this.
activity.setRequestedOrientation( 1 ) in your create method ( or indeed in a unittest )
does diddly squat, the orientation will always be 0, ie landscape, it seems the only way to get the orientation to change is to run it on a physical device.