Skip to content

Commit 748e40f

Browse files
committed
fix(openlist):Convert OpenListService from foreground to background service
1 parent 2c95038 commit 748e40f

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

android/app/src/main/AndroidManifest.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@
7575
<service
7676
android:name=".OpenListService"
7777
android:exported="true"
78-
android:foregroundServiceType="dataSync"
7978
tools:ignore="ExportedService" />
8079

8180
<receiver

android/app/src/main/kotlin/com/github/openlistteam/openlistflutter/OpenListService.kt

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,7 @@ class OpenListService : Service(), OpenList.Listener {
5858
.sendBroadcast(Intent(ACTION_STATUS_CHANGED))
5959

6060
if (!isRunning) {
61-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
62-
stopForeground(STOP_FOREGROUND_REMOVE)
63-
} else
64-
stopForeground(true)
65-
61+
// 后台服务不需要调用 stopForeground
6662
stopSelf()
6763
}
6864
}
@@ -71,7 +67,8 @@ class OpenListService : Service(), OpenList.Listener {
7167
override fun onCreate() {
7268
super.onCreate()
7369

74-
initOrUpdateNotification()
70+
// 移除前台服务通知,改为后台服务
71+
// initOrUpdateNotification()
7572

7673
if (AppConfig.isWakeLockEnabled) {
7774
mWakeLock = powerManager.newWakeLock(
@@ -106,7 +103,8 @@ class OpenListService : Service(), OpenList.Listener {
106103
mWakeLock?.release()
107104
mWakeLock = null
108105

109-
stopForeground(true)
106+
// 后台服务不需要调用 stopForeground
107+
// stopForeground(true)
110108

111109
LocalBroadcastManager.getInstance(this).unregisterReceiver(mReceiver)
112110
unregisterReceiver(mNotificationReceiver)

0 commit comments

Comments
 (0)