Skip to content

Commit 36a74f4

Browse files
#8964 Fix app crash on incoming call when running Android 14+
1 parent 6fc948d commit 36a74f4

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

changelog.d/8964.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix incoming call crash on Android 14+. ([#8964](https://github.com/element-hq/element-android/issues/8964))

vector/src/main/java/im/vector/app/features/call/VectorCallActivity.kt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,16 @@ class VectorCallActivity :
246246
== PackageManager.PERMISSION_GRANTED) {
247247
// Only start the service if the app is in the foreground
248248
if (isAppInForeground()) {
249-
Timber.tag(loggerTag.value).v("Starting microphone foreground service")
250-
val intent = Intent(this, MicrophoneAccessService::class.java)
251-
ContextCompat.startForegroundService(this, intent)
249+
// Starting in Android 14, you can't create a microphone foreground service while your app is in
250+
// the background. If we call startForegroundService the app will crash.
251+
// https://github.com/element-hq/element-android/issues/8964
252+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
253+
Timber.tag(loggerTag.value).v("Starting microphone foreground service")
254+
val intent = Intent(this, MicrophoneAccessService::class.java)
255+
ContextCompat.startForegroundService(this, intent)
256+
} else {
257+
Timber.tag(loggerTag.value).v("App is in running Android 14+; cannot start microphone service")
258+
}
252259
} else {
253260
Timber.tag(loggerTag.value).v("App is not in foreground; cannot start microphone service")
254261
}

0 commit comments

Comments
 (0)