Skip to content

Native Android client for Spotify, built with Jetpack Compose

MainActivity: detach the WebView in onDestroy

liliapk38cc9f035f0b
diff --git a/base/app/src/main/java/app/myspoti/MainActivity.kt b/base/app/src/main/java/app/myspoti/MainActivity.kt
index ddd6bcc9..17eb06a8 100644
--- a/base/app/src/main/java/app/myspoti/MainActivity.kt
+++ b/base/app/src/main/java/app/myspoti/MainActivity.kt
@@ -93,6 +93,14 @@ class MainActivity : AppCompatActivity() {
handle(intent)
}
+ override fun onDestroy() {
+ // The process-wide WebView lives in this activity's root while attached:
+ // detach it, or view.parent -> root keeps the destroyed activity (and its
+ // whole view tree) alive for the rest of the playback session.
+ MyspotiRuntime.host.detach()
+ super.onDestroy()
+ }
+
/** Spotify's login page, full screen, until the Web Player comes back signed in. */
private fun showLogin() {
showingLogin = true