From 750f07547c1a727127338743a175fd2e31448523 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Tue, 24 Sep 2024 15:46:19 +0200 Subject: [PATCH] Fix PiP crash with IllegalStateException. Activity must be resumed to enter PiP mode. https://sentry.tools.element.io/organizations/element/issues/1449388/events/2eb06349f6224481960a64916d51ae60/?project=59 --- .../android/features/call/impl/ui/ElementCallActivity.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/ui/ElementCallActivity.kt b/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/ui/ElementCallActivity.kt index 5cd8b55158..b55c39f41b 100644 --- a/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/ui/ElementCallActivity.kt +++ b/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/ui/ElementCallActivity.kt @@ -281,7 +281,11 @@ class ElementCallActivity : @RequiresApi(Build.VERSION_CODES.O) override fun enterPipMode(): Boolean { - return enterPictureInPictureMode(getPictureInPictureParams()) + return if (lifecycle.currentState.isAtLeast(Lifecycle.State.RESUMED)) { + enterPictureInPictureMode(getPictureInPictureParams()) + } else { + false + } } @RequiresApi(Build.VERSION_CODES.O)