Have you tried this in your activity?
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); //This is the default value setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
After that, you can use this to turn off automatic orientation:
public static void setAutoOrientationEnabled(ContentResolver resolver, boolean enabled) { Settings.System.putInt(resolver, Settings.System.ACCELEROMETER_ROTATION, enabled ? 1 : 0); }
Documentation
source share