2

I am in the phase where I migrate my app from Exoplayer to jetpack Media3 and I want to stop my MediaSessionService once the user delete the notification but in the MediaNotification.Provider we could not catch the event when the user deletes the Notification all what we have is to setDeleteIntent and here I want to stop the Notification some solutions that i found like write a BroadcastReciever and do that in onRecieve() method but it looks for me over engineering. has anyone a soultion ?

Thanks in advance

DoctorDoom
  • 501
  • 2
  • 8
  • 21

1 Answers1

0

Have you tried overriding onTaskRemoved()? Like -

override fun onTaskRemoved(rootIntent: Intent?) {
    super.onTaskRemoved(rootIntent)
    mediaSession.player.release()
    stopForeground(STOP_FOREGROUND_REMOVE)
}
  • 1
    Thank you very much for your Answer, but the above method will be triggered when the user stops the App from settings and I already implemented the method and it didn't helped. – DoctorDoom May 24 '23 at 07:44