ARTICLE DETAIL

资讯详情

深耕网站建设、视觉设计与SEO优化的一线实战洞察。

android开发aosp launcher定制开发设置landscape横屏无效的解决方法

android开发aosp launcher定制开发设置landscape横屏无效的解决方法
1. shell测试
  1. 先关闭自动旋转
    adb shell content insert --uri content://settings/system --bind name:s:accelerometer_rotation --bind value:i:0
  2. 强制设为横屏 (1 或 3)
    adb shell content insert --uri content://settings/system --bind name:s:user_rotation --bind value:i:1
2. 代码实现
//ShellUtils工具类依赖 implementation "com.blankj:utilcode:1.30.7"
//在launcher应用启动的Application里执行下面两行代码,实现方式有点取巧,因为改不了aosp代码
ShellUtils.execCmd("content insert --uri content://settings/system --bind name:s:accelerometer_rotation --bind value:i:0",false
)
ShellUtils.execCmd("content insert --uri content://settings/system --bind name:s:user_rotation --bind value:i:1",false
)
返回列表