mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-08-22 01:51:47 +00:00
Ignore ForegroundServiceStartNotAllowedException
This commit is contained in:
parent
dbbce2aee1
commit
feae6b54a9
@ -234,7 +234,12 @@ class BackgroundService : Service() {
|
|||||||
Log.d(LOG_TAG, "onStartCommand")
|
Log.d(LOG_TAG, "onStartCommand")
|
||||||
if (NotificationHelper.isPersistentNotificationEnabled(this)) {
|
if (NotificationHelper.isPersistentNotificationEnabled(this)) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||||
startForeground(FOREGROUND_NOTIFICATION_ID, createForegroundNotification(), ServiceInfo.FOREGROUND_SERVICE_TYPE_CONNECTED_DEVICE)
|
try {
|
||||||
|
startForeground(FOREGROUND_NOTIFICATION_ID, createForegroundNotification(), ServiceInfo.FOREGROUND_SERVICE_TYPE_CONNECTED_DEVICE)
|
||||||
|
} catch (e: IllegalStateException) { // To catch ForegroundServiceStartNotAllowedException
|
||||||
|
Log.w("BackgroundService", "Couldn't startForeground", e);
|
||||||
|
return START_STICKY
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
startForeground(FOREGROUND_NOTIFICATION_ID, createForegroundNotification())
|
startForeground(FOREGROUND_NOTIFICATION_ID, createForegroundNotification())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user