gpt4 book ai didi

Android O 对较低目标 SDK 的限制

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:41:55 24 4
gpt4 key购买 nike

我开始使用 Android O 在 Nexus 5x 上测试我的应用。
我的 targetSdkVersion 是 22。
在开发者网站上,我读到了 Background execution limits :
其中:
默认情况下,这些限制仅适用于面向 O 的应用。但是,用户可以从“设置”屏幕为任何应用启用这些限制,即使该应用并未面向 O。

  1. 这些设置在哪里(以执行 Android O 限制)?
  2. 什么是这些限制的最佳实践,而我仍然想要保持较低的 targetSdkVersion

最佳答案

我在 App info > Battery usage 下找到了设置,但并非所有应用都有此设置。

当此设置关闭时,我会看到以下日志:

W/BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.$ACTION dat=package:$APP_PACKAGE flg=0x4000010 (has extras) } to $APP_PACKAGE/$APP_RECEIVER

App Info > Battery usage

[2017 年 9 月 27 日更新]

如所述here :

However, developers cannot use the Settings app to apply this limitation, unless their app happens to be in the battery blame list, which ideally doesn’t happen.

本文提供了通过以下命令测试后台限制的未记录方法(ignoreallow 值是可能的)

adb shell appops set your.application.id.here RUN_IN_BACKGROUND ignore 

最佳实践是

  • If you plan on sticking with a lower targetSdkVersion for a while, and you are really really sure that your app will not show up on the battery blame list, and you want to ignore the background limitations for now, that’s your decision to make.

  • If, however, you plan on sticking with a lower targetSdkVersion and your app does tend to consume a fair bit of battery life, you should test your app with the adb shell appops command cited above. If nothing else, you can identify the likely symptoms that users will experience if they limit your background work through the Battery screen in Settings. That way, if you get customer service calls/emails/texts/Play Store comments/candygrams about those symptoms, you can better advise users about what to do.

另见 Android Oreo Background Execution Limits

关于Android O 对较低目标 SDK 的限制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44484937/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com