Skip to content

Commit

Permalink
#8964 Fix app crash on incoming call when running Android 14+
Browse files Browse the repository at this point in the history
  • Loading branch information
christianrowlands committed Jan 13, 2025
1 parent 6fc948d commit 36a74f4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions changelog.d/8964.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix incoming call crash on Android 14+. ([#8964](https://github.com/element-hq/element-android/issues/8964))
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,16 @@ class VectorCallActivity :
== PackageManager.PERMISSION_GRANTED) {
// Only start the service if the app is in the foreground
if (isAppInForeground()) {
Timber.tag(loggerTag.value).v("Starting microphone foreground service")
val intent = Intent(this, MicrophoneAccessService::class.java)
ContextCompat.startForegroundService(this, intent)
// Starting in Android 14, you can't create a microphone foreground service while your app is in
// the background. If we call startForegroundService the app will crash.
// https://github.com/element-hq/element-android/issues/8964
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
Timber.tag(loggerTag.value).v("Starting microphone foreground service")
val intent = Intent(this, MicrophoneAccessService::class.java)
ContextCompat.startForegroundService(this, intent)
} else {
Timber.tag(loggerTag.value).v("App is in running Android 14+; cannot start microphone service")
}
} else {
Timber.tag(loggerTag.value).v("App is not in foreground; cannot start microphone service")
}
Expand Down

0 comments on commit 36a74f4

Please sign in to comment.