[英]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.