I have an application that I just would like to use in portrait mode, so I have defined android:screenOrientation=\"portrait\" in the manifest XML. This works OK for the HTC
As said, set android:configChanges
of your Activity (in manifest file) to keyboardHidden|orientation
and then:
1) Override onConfigurationChanged()
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
//here you can handle orientation change
}
2) Add this line to your activity's onCreate()
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
It's better than add same line to onConfigurationChanged
, because your app will turn to portrait mode and then back to landscape (it will happen only one time, but it's annoying).
Also you can set android:screenOrientation="nosensor"
for your activity (in manifest). But using this way you're a not able to handle orientation changes at all.