From 7f159cb682aee005322f817678595cd5fd9eb407 Mon Sep 17 00:00:00 2001 From: czlucius <58442255+czlucius@users.noreply.github.com> Date: Tue, 31 Aug 2021 18:27:17 +0800 Subject: [PATCH] For #18727: Exit PiP when launched externally with Intents --- app/src/main/java/org/mozilla/fenix/HomeActivity.kt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/src/main/java/org/mozilla/fenix/HomeActivity.kt b/app/src/main/java/org/mozilla/fenix/HomeActivity.kt index a5ec4f3338f9..ff30956a99dd 100644 --- a/app/src/main/java/org/mozilla/fenix/HomeActivity.kt +++ b/app/src/main/java/org/mozilla/fenix/HomeActivity.kt @@ -7,6 +7,7 @@ package org.mozilla.fenix import android.content.Context import android.content.Intent import android.content.Intent.ACTION_MAIN +import android.content.Intent.FLAG_ACTIVITY_REORDER_TO_FRONT import android.content.res.Configuration import android.os.Build import android.os.Bundle @@ -188,6 +189,12 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity { super.onCreate(savedInstanceState) } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && isInPictureInPictureMode && intent != null) { + // Exit PiP mode + moveTaskToBack(false) + startActivity(Intent(this, this::class.java).setFlags(FLAG_ACTIVITY_REORDER_TO_FRONT)) + } + // Diagnostic breadcrumb for "Display already aquired" crash: // https://github.com/mozilla-mobile/android-components/issues/7960 breadcrumb(