三星“应用优化"功能在 3 天后杀死后台应用程序 [英] Samsung "App optimisation" feature kills background applications after 3 days

查看:38
本文介绍了三星“应用优化"功能在 3 天后杀死后台应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们目前正在开发一款 Android 应用,它是一款健身追踪器应用.它在后台持续运行,在大多数设备上运行良好,但我们一直遇到应用程序在某些三星设备上完全死机的问题.经过一番调查,似乎某些三星设备具有完全自定义的应用优化"功能(http://forums.androidcentral.com/samsung-galaxy-s6/599408-app-optimisation-after-updating.html),这基本上是一个(非常)原始的存在于更高版本的 Android 中的 Doze 功能的一个版本,如果应用程序三天没有使用,它基本上只会谋杀应用程序.

We are currently developing an Android app that is a fitness-tracker application. It runs constantly in the background, and it works fine on most devices, but we've been having issues with the application dying completely on some Samsung devices. After some investigation, it seems like some Samsung devices has a completely custom "App Optimisation" feature (http://forums.androidcentral.com/samsung-galaxy-s6/599408-app-optimisation-after-updating.html), which is basically a (very) primitive version of the Doze feature that exists in later versions of Android which basically just murders apps if they haven't been used for three days.

由于这个应用程序或多或少只做日志记录,并没有打开活动,这对我们来说是一个大问题,因为许多三星设备都预先启用了此功能.问题是通过使用前台服务解决的,但这是一个解决方案的大锤,需要通过不断的通知来打扰用户,而且我们真的不需要应用程序在前台 - 我们对正常电源没问题安卓的管理.

As this app is more or less only doing logging, and doesn't open the activity, it presents a big problem for us, because this feature is pre-enabled on many Samsung devices. The problem is solved by using a foreground service, but that is a sledgehammer of a solution that requires disturbing the user with a constant notification, and we really don't need the app to be in the foreground - we are fine with the normal power management of Android.

三星应用优化功能明确指出,如果应用三天未使用,它将优化"应用.有人知道三星认为使用"了什么,我可以以某种方式触发它吗?

The Samsung App Optimisation feature clearly states that it will "optimise" apps if they have not been used for three days. Does anyone have insight in what Samsung considers to be "used" and can I somehow trigger that?

旁白:在我看来,这是一个实施不当的功能,使 Android 上的开发更具敌意.除了我们的用例之外,它还会破坏任何信使应用程序.如果不是因为 Facebook Messenger 和 Whatsapp 被硬连接到应用程序豁免,用户会发疯,因为这会破坏他们的体验.

Side-rant: In my opinion, this is a badly implemented feature that makes development on Android more hostile. Besides our use case, it will any messenger applications break. If it were not for the fact that Facebook Messenger and Whatsapp are hard-wired to be exempt for the app, users would be going crazy because it would be breaking their experiences.

推荐答案

我拥有(并且目前拥有)三星设备,所以我从用户的角度对它的工作原理有所了解.技术规格及其内部工作原理是一个完全不同的问题,我无法回答.

I've owned (and currently own) Samsung devices, so I know a little as to how it works from the user's point of view. The technical specifications and how it works on the inside is an entirely separate issue, and one I can't answer.

系统可以检测您是否打开了应用程序.三星在他们的应用程序优化中使用了这一点,并将为超过三天未使用的应用程序节省电量.不过,这是一个糟糕的系统.

The system can detect if you open an app. Samsung uses that in their app optimization, and will save power on apps that haven't been used in over three days. It is a terrible system though.

它会忽略可能对应用至关重要的后台进程,即使它是您积极使用的应用,例如健身追踪器,它也会出现问题.引用应用优化列表中的内容:

It ignores background-processes that may be critical to apps, and even if it is an app you actively use, like a fitness tracker, it will have issues. To quote what it says inside the app optimization-list:

"为了节省电池电量,超过 3 天未使用的应用将被指定为节省电量.指定用于省电的应用可能不会显示通知"

"To save battery power, apps that haven't been used for more than 3 days will be designated to save power. Apps designated to save power may not show notifications"

(挪威语的粗译,最初取自运行 Android 6 的 S6)

(Rough translation from Norwegian, originally taken from an S6 running Android 6)

因此,手动或自动设置(3 天未使用)的应用可能会导致后台进程出现各种问题.但请记住,用户可以将任何应用设置为从不省电,而忽略自动设置.因此,考虑到这一点,让我们考虑可能的解决方案.

Therefore, apps that have been manually, or automatically set (3 days of no use) may give various issues with background processes. But remember that the user can set any app to never save battery, and ignoring the automatic setting. So with this in mind, let's consider possible solutions.

有一种情况,您无需担心应用和应用优化:当应用优化被完全禁用时.

There is one scenario where you do not need to worry about the app and app optimization: When app optimization is disabled entirely.

除此之外,您实际上只能做两件事:

Looking aside that, there is really only two things you can do:

  1. 要求三星用户为您的应用禁用电池优化以防止出现问题

  1. Ask users on Samsung to disable battery optimization for your app to prevent issues

正如@MinaSamy 所建议的(在他们现在删除的答案中),SyncAdapter 和定期同步.请注意,我没有测试过这个,所以我不知道它是否有效.

As @MinaSamy suggested (in their now deleted answer), SyncAdapter and having a periodic synchronization. Note that I haven't tested this, so I don't know whether it works or not.

还有第三种选择,这确实不是解决方案,但您可以忽略它并赌上禁用应用优化,或者根本不关心它.

And there's also a third option, which really isn't a solution, but you can ignore it and gamble on app optimization being disabled, or just not care about it at all.

有没有人了解三星认为是使用"的东西?我可以以某种方式触发它吗?

Does anyone have insight in what Samsung considers to be "used" and can I somehow trigger that?

据我所知,除非三星添加一些防止意外打开的保护措施或添加某种最低活动要求,否则打开就足够了.这似乎是一个愚蠢的"功能,它运行在硬编码规则上,而不是一个动态系统,它实际检测应用程序使用情况并设置与之相关的省电.它易于启用",但幸运的是,它也很容易禁用.

As far as I know, unless Samsung added some safeguards against accidental opening or added some kind of minimum activity requirement, opening is enough. It appears to be a "stupid" feature, which runs on hard-coded rules rather than a dynamic system that actually detects app use and sets power saving relative to that. It's "easy to enable", but fortunately easy to disable as well.

意味着你不能触发一个事件来让它保持活动状态(除非 SyncAdapter 成功了)

Meaning you cannot trigger an event that will keep it alive (unless SyncAdapter does the trick)

为了澄清事实,来自 @Neil 的回答:

And to make the facts clear, from @Neil's answer:

看起来用户确实可以做到这一点,所以必须有一些数据库或设置来控制它.

It does seem like the user can do this, so there must be some database or setting somewhere that controls it.

有一点.总共有四个设置,其中三个是特定于应用程序的,并且存储在数据库中(或某种其他形式的数据存储).这四个设置虽然非常浅显,但可用于改变应用优化的行为:

There kinda is. There are a total of four settings, three of which are app-specific, and it is stored in a database (or some other form of data storage). These four settings can be used, although extremely shallow, to alter the behavior of the app optimization:

  • 始终优化
  • 自动优化
  • 从不优化
  • 禁用应用优化

前三个选项是基于每个应用的,这意味着每个应用可以有单独的设置.禁用应用优化正是您所期望的:它会禁用所有应用的整个功能.如果完全禁用,则不会进行任何优化.

The first three options are on a per-app basis, which means each app can have separate settings. Disabling app optimization is exactly what you'd expect: it disables the entire feature for all apps. If it's disabled entirely, nothing is optimized.

还有一个网站列出了按品牌绕过优化的方法.三星的条目或多或少是我所说的:告诉用户手动禁用优化.没有开发者解决方案.

There's also a website listing ways of bypassing optimizations on a per-brand basis. The entry for Samsung is more or less what I've said: tell the user to manually disable optimization. There are no developer solutions.

这篇关于三星“应用优化"功能在 3 天后杀死后台应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆