小米/华为/熔岩上的RAM已满后,粘性服务无法重新启动 [英] Sticky Service not restarting after RAM full on Xiaomi / Huawei / Lava

查看:119
本文介绍了小米/华为/熔岩上的RAM已满后,粘性服务无法重新启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个粘性服务,我正在通过填充手机的RAM来对应用程序进行压力测试.一旦RAM已满,服务将被销毁.由于它是一项粘性服务,因此在系统有足够资源时会自动重新启动.

I have a Sticky Service and i'm stress testing the app by filling the phone's RAM. Once the RAM is full, the service is destroyed. Since it's a sticky service, it gets restarted automatically when the system has enough resources.

但这仅在诸如Moto/Nexus之类的普通android设备上发生.小米或熔岩之类的设备即使在5.1上也不会重新启动粘性服务.

But this happens only on stock android devices like Moto/Nexus. Devices like Xiaomi or Lava do not restart the sticky service, even on 5.1

有人通过高度定制的ROM意识到这种问题吗?有什么变通办法可以安排在内存不足时重新启动我的服务?

Is anyone aware of such problems with heavily customized ROMs? Any workarounds to schedule a restart of my service when the memory gets low?

推荐答案

所有类似android的库存设备都能正常工作,因为它们使用AOSP ROM

All stock android devices like works well because they use AOSP ROM's

这些设备(HUAWEI,LAVA,XIAOMI)出厂时已预装了启动管理器或节能器(大多数华为设备).如果未正确配置该应用,则该服务将在屏幕关闭后几秒钟/分钟被终止-否则重启后将不会自动启动.

These devices(HUAWEI,LAVA,XIAOMI) are shipped with pre-installed start managers or energy savers (most of the Huawei devices). If the app is not configured appropriately the services will be killed several seconds/minutes after the screen turns off - or it will not automatically be started after reboot.

现在有了名为受保护的应用程序"的功能,我尝试在我的应用程序中启用该功能,但在应用程序终止后,粘性服务仍未开始. 此外,进一步的观察是:-HUAWEI设备甚至不提供前台服务

Now with the feature called Protected Apps, I tried enabling in my app and still the sticky service is not getting started post the App Kill. also, furher observation is:-- The HUAWEI device does not even hold a foreground service

现在可能的解决方法是:-

Now the possible workaround is:--

我们可以使用Alarm Manager类来确保该服务是 在必要时运行.因此,该警报管理器可以用来 创建一个计时器,不时检查该服务是否应 运行并重新启动它.这个时间间隔需要考虑 可能会对电池消耗产生影响.

We can use Alarm Manager class to make sure that the service is running when it's necessary. So this Alarm manager can be used to create a timer which checks from time to time if the service should be running and restart it. This time interval needs to be set considering the possible impact on battery consumption.

这篇关于小米/华为/熔岩上的RAM已满后,粘性服务无法重新启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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