This question already has an answer here:
When I press a button, I would like to disable screen rotation on all my activities. How can I do that?
BTW, the phone can be located in landscape or portrait position when the user click the button.
This question already has an answer here:
When I press a button, I would like to disable screen rotation on all my activities. How can I do that?
BTW, the phone can be located in landscape or portrait position when the user click the button.
You can change your AndroidManifest.xml to
Which informs the OS that you will handle these config changes (by doing nothing.)
See How do I disable orientation change on Android?
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
I've found the solution:
in manifest.xml:
in MyApplication.java: