简体   繁体   English

BroadcastReceiver在几个小时后停止了对小米的工作

[英]BroadcastReceiver stop working on Xiaomi after couple of hours

I'm using Awareness API for my project and receiving actions via BroadcastReceiver . 我正在为我的项目使用Awareness API并通过BroadcastReceiver接收操作。 This is the question with my code: link . 这是我的代码的问题: 链接 The problem is that everything works fine in all android version except in Xiaomi devices. 问题是除了小米设备外,所有Android版本都能正常运行。 Where BroadcastReceiver not receiving anything after couple of hours. BroadcastReceiver在几个小时后没有收到任何东西。 I have tried many solution for this (such as this and this and turning battery saving off for my app), but nothing seems to work. 我已经尝试了很多解决方案(比如这个这个并为我的应用程序关闭电池节省),但似乎没有任何工作。

Google Awareness : 谷歌意识

And whilst doing so, the API collates data from multiple sources to ensure that the data provided is both accurate and of a high quality. 在这样做时,API会整理来自多个来源的数据,以确保所提供的数据既准确又高质量。 It also takes into account both the power and memory consumption when accessing these signals - helping to ensure that the battery life and memory usage of our applications do not have a detrimental effect on the users device. 它还在访问这些信号时考虑了功耗和内存消耗 - 有助于确保我们的应用程序的电池寿命和内存使用不会对用户设备产生不利影响。

As this paragraph says: 正如本段所说:

It also takes into account both the power and memory consumption when accessing these signals 它还会在访问这些信号时考虑功耗和内存消耗

and you say: 你说:

The problem is that everything works fine in all android version except in Xiaomi devices. 问题是除了小米设备外,所有Android版本都能正常运行。 Where BroadcastReciver not receiving anything after couple of hours BroadcastReciver 在几个小时后没有收到任何东西

after couple of hours device may going to save more energy 经过几个小时,设备可能会节省更多能源

You are listening for "Fence API" to register for changes in the users current environment it may consumes power and thus you do not receive broadcasts you may need to change the device settings to allow using of sensors such as location GPS and other relevant sensors 您正在侦听“Fence API”以注册用户当前环境中可能消耗功率的更改,因此您无法接收更改设备设置以允许使用位置GPS和其他相关传感器等传感器的广播

I think your problem is about battery optimization. 我认为你的问题是关于电池优化。 This feature is available beginning from Android Marshmallow, that introduced Doze mode. 此功能从Android Marshmallow开始提供,它引入了Doze模式。 It's a way of reducing battery consumption for background apps, but in your case you should disable it for your app. 这是一种减少后台应用程序电池消耗的方法,但在您的情况下,您应该为您的应用程序禁用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM