How to set the screen orientation to Landscape mode in a activity when the auto rotation feature is turned off in the device settings in Android -


well, have requirement, orientation of screen should changed, when phone turned when auto-rotation feature off on android-device settings.

i know can achieved using the

setrequestedorientation(activityinfo.screen_orientation_sensor); 

in oncreate of activity.

or by

@override public void onconfigurationchanged(configuration newconfig)  { super.onconfigurationchanged(newconfig); setrequestedorientation(activityinfo.screen_orientation_sensor); } 

any tips or best practices or code snippets can achieve this? way of implemenatation right? helpful if has managed achieve within custom views or fragments share logic on how implemented. help!

i know can done in androidmanifest file adding tag, limit layout in landscape , not i'm looking for.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -