Skip to content

Commit

Permalink
Merge pull request #1462 from Malopieds/kill-service
Browse files Browse the repository at this point in the history
Fix crash onDestroy when rotating
  • Loading branch information
z-huang authored Aug 27, 2024
2 parents 0fd93da + e2f9800 commit d921b0a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion app/src/main/java/com/zionhuang/music/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ class MainActivity : ComponentActivity() {

override fun onDestroy() {
super.onDestroy()
if (dataStore.get(StopMusicOnTaskClearKey, false) && playerConnection?.isPlaying?.value == true) {
if (dataStore.get(StopMusicOnTaskClearKey, false) && playerConnection?.isPlaying?.value == true && isFinishing) {
stopService(Intent(this, MusicService::class.java))
unbindService(serviceConnection)
playerConnection = null
Expand Down

0 comments on commit d921b0a

Please sign in to comment.