[英]Flutter app does not come to foreground when tapped on native android background service notification
[英]on android 8, will the background child process get suspended when app has a service and a notification in the foreground?
我的应用程序在由 C 编写的本机可执行文件中有一个代理服务器,它总是在后台运行,我们称之为 httpproxy.exe。 主要活动我使用 startForegroundService 和 startForeground 并带有持久通知,以将应用程序保持在前台以避免被系统杀死,然后在后台运行 httpproxy.exe。
我的应用程序在 android 5 及更早版本上运行良好,但在 android 8.0 上,当活动在几分钟后进入后台时,httpproxy.exe 看起来像是被挂起,所以我必须一次又一次地启动我的应用程序,这是不可接受的。
我听说android 8 上有一个所谓的后台执行限制,我怎样才能让我的应用程序像以前一样正常工作?
确保您的应用被排除在打盹模式之外。
检查:
PowerManager powerManager =
(PowerManager)getActivity().getSystemService(Activity.POWER_SERVICE);
powerManager.isIgnoringBatteryOptimizations(getActivity().getPackageName());
要求用户将您的应用列入白名单:
Intent intent = new Intent(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS);
startActivity(intent);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.