FYI:如果一些应用程序不用于长时间的android系统,将应用程序置于睡眠模式!
ques:有没有办法防止它在颤动,因为我的后台进程不能在深度睡眠模式下工作&我不会收到FCM的通知消息吗?
尝试忽略电池优化
var status = await permissionHandler.Permission.ignoreBatteryOptimizations.status;
if (!status.isGranted) {
var status = await permissionHandler.Permission.ignoreBatteryOptimizations.request();
if (status.isGranted) {
debugPrint("Good, all your permission are granted, do some stuff");
} else {
debugPrint("Do stuff according to this permission was rejected");
}
}
它还需要AndroidManifest.xml中的权限,如下所示:
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />