Changing Android Device orientation with ADB

前端 未结 3 1402
遥遥无期
遥遥无期 2020-12-13 00:23

I\'m using Android 4.4 on a real device and I want to set the device orientation via adb. I don\'t want it done with uiautomator since it won\'t last after the

3条回答
  •  旧巷少年郎
    2020-12-13 01:02

    Disable accelerometer_rotation and set the user_rotation


    user_rotation Values:
    0           # Protrait 
    1           # Landscape
    2           # Protrait Reversed
    3           # Landscape Reversed
    
    accelerometer_rotation Values:
    0           # Stay in the current rotation
    1           # Rotate the content of the screen
    

    Example using adb:

    adb shell settings put system accelerometer_rotation 0
    adb shell settings put system user_rotation 3
    

    Example programmatically:

    import android.provider.Settings;
    
    // You can get ContentResolver from the Context
    Settings.System.putInt(getContentResolver(), Settings.System.ACCELEROMETER_ROTATION, 0);
    Settings.System.putInt(getContentResolver(), Settings.System.USER_ROTATION, 3);
    

提交回复
热议问题