Skip to content

Commit 0c8305d

Browse files
bngshyonghanJu
andcommitted
🐛 앱 종료 시 워크매니저 종료되던 버그 해결
Co-authored-by: yonghanJu <[email protected]>
1 parent 0a62753 commit 0c8305d

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

presentation/src/main/AndroidManifest.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
<meta-data android:name="com.whyranoid.presentation.running.WorkManagerInitializer"
2222
android:value="androidx.startup" />
2323
</provider>
24+
<service
25+
android:name="androidx.work.impl.foreground.SystemForegroundService"
26+
android:foregroundServiceType="location"
27+
tools:node="merge" />
2428
</application>
2529

2630
</manifest>

presentation/src/main/java/com/whyranoid/presentation/running/RunningWorker.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import android.content.Intent
99
import android.location.Location
1010
import android.location.LocationListener
1111
import android.location.LocationManager
12+
import android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_LOCATION
1213
import android.os.Build
1314
import android.os.Looper
1415
import androidx.annotation.RequiresApi
@@ -74,6 +75,9 @@ class RunningWorker @AssistedInject constructor(
7475
.setOngoing(true)
7576
.build()
7677

78+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
79+
return ForegroundInfo(NOTIFICATION_ID, notification, FOREGROUND_SERVICE_TYPE_LOCATION)
80+
}
7781
return ForegroundInfo(NOTIFICATION_ID, notification)
7882
}
7983

0 commit comments

Comments
 (0)