Android 10.0适配

176 阅读1分钟

持续更新中,待完善

一、分区存储

二、后台定位限制

三、后台启动activity限制

四、深色主题适配

img

Dark theme

Dark theme is available in Android 10 (API level 29) and higher. It has many benefits:

  • Can reduce power usage by a significant amount (depending on the device’s screen technology).
  • Improves visibility for users with low vision and those who are sensitive tobright light.
  • Makes it easier for anyone to use a device in a low-light environment.

Dark theme applies to both the Android system UI and apps running on the device.

There are three ways to enable Dark theme in Android 10 (API level 29) and higher:

  • Use the system setting (Settings -> Display -> Theme) to enable Dark theme.
  • Use the Quick Settings tile to switch themes from the notification tray (once enabled).
  • On Pixel devices, selecting the Battery Saver mode enables Dark theme at the same time. Other OEMs may or may not support this behavior.

上面一段是官网上对深色主题的好处和开启方式的描述。适配深色主题主要有以下好处

  1. 减少能耗(取决于设备屏幕的材质,现在大部分手机使用的OLED屏幕显示黑色的时候不会发光)
  2. 弱光环境下减少屏幕亮光对眼睛的刺激和伤害

让应用支持深色主题

为了让应用能够支持深色主题,我们必须要修改我们的主题(res/values/styles.xml)为DayNight.

<style name="AppTheme" parent="Theme.AppCompat.DayNight">

或者使用MaterialComponents的深色主题

<style name="AppTheme" parent="Theme.MaterialComponents.DayNight">

友情链接:

juejin.cn/post/684490…

官网

五、标识符获取限制

六、折叠屏适配