May I check how can I rotate screen via code in Android?
The device (Android 6 ARM CPU) I am using does not have sensor to detect orientation change and I need to do it manually.
The problem of this device is it will not save the setting, once I change the screen orientation via Setting menu.
The next time its power on, it will go back to default "Landscape".
I tried to use below codes (one at a time) to change it, it is not working (means screen no change).
Settings.System.putInt(contentResolver, Settings.System.USER_ROTATION, 1);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
On this device, there are two options (Screen rotation and External screen rotation).
I need to change both orientation to achieve what I want via Settings - Display option.
Either Kotlin or Java codes are Ok for me. Any advice?



You can't rotate android core from in you application, but you can create the custom layout in your project and controlled by your self like this :
first create custom layout :
Second add this to your layout, xml file like this :
finally use it in your activity or fragment like this :