How to rotate the screen to landscape (or portrait) by programmable way? I am trying to make it independent when user rotates the screen.
Is it possible thing ?
Thanks in advance.
Use Rotation Control to force screen orientation of Android devices. Once you've installed, open the app and just tap to turn it on. You can even start it when you restart your phone. This will help you when you don't want to open the again and again after every reboot.
Try this:
Activity.setRequestedOrientation()
with these parameters:
ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
Check this for further reference
You can try with the sample below...
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
// You can set the value initially by
// ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED. Once set it
// retains it's value. The View will be rendered in the specified
// orientation using the code below.
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With