When I press a button, I would like to disable screen rotation on all my activities. How can I do that?
BTW, phone can be located in landscape|portrait position when user click the button. ...
When I press a button, I would like to disable screen rotation on all my activities. How can I do that?
BTW, phone can be located in landscape|portrait position when user click the button. ...
You can change your AndroidManifest.xml to
<activity android:name="MainActivity" android:configChanges="orientation">
Which informs the OS that you will handle these config changes (by doing nothing.)
See http://stackoverflow.com/questions/1512045/how-to-disable-orientation-change-in-android
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
I've found the solution:
in manifest.xml:
<application android:icon="@drawable/icon" android:label="@string/app_name" android:theme="@android:style/Theme.NoTitleBar" android:name="MyApplication">
in MyApplication.java:
public class UPackingListApplication extends Application {
public void onConfigurationChanged(Configuration newConfig) {
newConfig.orientation = [orientation we wanna to use (according to ActivityInfo class)];
super.onConfigurationChanged(newConfig);
}
}