Should fix the remaining ForegroundServiceStartNotAllowedException
This commit is contained in:
parent
f3ad232c1f
commit
91a23cb286
2 changed files with 16 additions and 1 deletions
|
@ -51,6 +51,10 @@
|
|||
(https://developer.android.com/guide/topics/connectivity/bluetooth/permissions) -->
|
||||
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
|
||||
|
||||
<!-- Needed for foreground service
|
||||
(https://developer.android.com/guide/components/foreground-services) -->
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
|
||||
|
||||
<application
|
||||
android:name=".LinphoneApplication"
|
||||
android:allowBackup="false"
|
||||
|
|
|
@ -372,7 +372,18 @@ class NotificationsManager(private val context: Context) {
|
|||
Log.i("[Notifications Manager] Starting service as foreground using call notification [$notificationId]")
|
||||
try {
|
||||
currentForegroundServiceNotificationId = notificationId
|
||||
service?.startForeground(currentForegroundServiceNotificationId, callNotification)
|
||||
|
||||
val coreService = service
|
||||
if (coreService != null) {
|
||||
Compatibility.startForegroundService(
|
||||
coreService,
|
||||
currentForegroundServiceNotificationId,
|
||||
callNotification
|
||||
)
|
||||
} else {
|
||||
Log.w("[Notifications Manager] No Service found, can't start it as foreground")
|
||||
currentForegroundServiceNotificationId = 0
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.e("[Notifications Manager] Foreground service wasn't allowed! $e")
|
||||
currentForegroundServiceNotificationId = 0
|
||||
|
|
Loading…
Reference in a new issue