diff --git a/app/src/main/java/com/vitorpamplona/amethyst/service/playback/PlaybackService.kt b/app/src/main/java/com/vitorpamplona/amethyst/service/playback/PlaybackService.kt index f1e80b39ff..2660b318aa 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/service/playback/PlaybackService.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/service/playback/PlaybackService.kt @@ -1,5 +1,7 @@ package com.vitorpamplona.amethyst.service.playback +import android.content.Intent +import android.util.Log import androidx.annotation.OptIn import androidx.media3.common.util.UnstableApi import androidx.media3.datasource.okhttp.OkHttpDataSource @@ -58,6 +60,8 @@ class PlaybackService : MediaSessionService() { override fun onCreate() { super.onCreate() + Log.d("Lifetime Event", "PlaybackService.onCreate") + // Stop all videos and recreates all managers when the proxy changes. HttpClient.proxyChangeListeners.add(this@PlaybackService::onProxyUpdated) } @@ -73,7 +77,15 @@ class PlaybackService : MediaSessionService() { toDestroyProgressive?.releaseAppPlayers() } + override fun onTaskRemoved(rootIntent: Intent?) { + super.onTaskRemoved(rootIntent) + + Log.d("Lifetime Event", "onTaskRemoved") + } + override fun onDestroy() { + Log.d("Lifetime Event", "PlaybackService.onDestroy") + HttpClient.proxyChangeListeners.remove(this@PlaybackService::onProxyUpdated) managerHls?.releaseAppPlayers() diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/MainActivity.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/MainActivity.kt index 11d4698f21..e8cfd0a60f 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/MainActivity.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/MainActivity.kt @@ -65,6 +65,8 @@ class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) + Log.d("Lifetime Event", "MainActivity.onCreate") + setContent { val sharedPreferencesViewModel: SharedPreferencesViewModel = viewModel() @@ -106,6 +108,8 @@ class MainActivity : AppCompatActivity() { override fun onResume() { super.onResume() + Log.d("Lifetime Event", "MainActivity.onResume") + // starts muted every time DefaultMutedSetting.value = true @@ -130,6 +134,8 @@ class MainActivity : AppCompatActivity() { } override fun onPause() { + Log.d("Lifetime Event", "MainActivity.onPause") + LanguageTranslatorService.clear() serviceManager.cleanObservers() @@ -152,11 +158,28 @@ class MainActivity : AppCompatActivity() { super.onPause() } + override fun onStart() { + super.onStart() + + Log.d("Lifetime Event", "MainActivity.onStart") + } + + override fun onStop() { + super.onStop() + + Log.d("Lifetime Event", "MainActivity.onStop") + } + override fun onDestroy() { + Log.d("Lifetime Event", "MainActivity.onDestroy") + + GlobalScope.launch(Dispatchers.IO) { + keepPlayingMutex?.stop() + keepPlayingMutex?.release() + keepPlayingMutex = null + } + super.onDestroy() - keepPlayingMutex?.stop() - keepPlayingMutex?.release() - keepPlayingMutex = null } /** diff --git a/app/src/play/java/com/vitorpamplona/amethyst/service/notifications/PushNotificationReceiverService.kt b/app/src/play/java/com/vitorpamplona/amethyst/service/notifications/PushNotificationReceiverService.kt index 1c7f476623..b35af836c7 100644 --- a/app/src/play/java/com/vitorpamplona/amethyst/service/notifications/PushNotificationReceiverService.kt +++ b/app/src/play/java/com/vitorpamplona/amethyst/service/notifications/PushNotificationReceiverService.kt @@ -50,7 +50,14 @@ class PushNotificationReceiverService : FirebaseMessagingService() { } } + override fun onCreate() { + super.onCreate() + Log.d("Lifetime Event", "PushNotificationReceiverService.onCreate") + } + override fun onDestroy() { + Log.d("Lifetime Event", "PushNotificationReceiverService.onDestroy") + scope.cancel() super.onDestroy() }