My application notifications should appear even when the phone is silent. This is a prayer app and, for example, the notification needs to sound when it comes to prayer even if the phone is in silent mode at night, which can sometimes be long (eg: like adhan).
I used the MediaPlayer library for this and I can play sound in a healthy way, even if my application is closed (this is what it should be). However, when you click on the notification or swipe left or right, this playing mediaplayer should stop, but it doesn't. I set the background service and tried to check it there but couldn't catch the notification swiping left or right, it still won't stop.
When I add an action with PendingIntent for the notification (I add it as builderNotify.addAction (R.drawable.notify_icon, "Stop", actionIntent);) and this time when I click this action it just stops, but then it returns an error in the background.
Can you help me?
Edit: I managed to stop it when the notification was swiped right or left. However, when the user clicks on the notification and enters the application, the mediaplayer continues to play.
My solution for what you need: I added services containing 2 Broadcast Receivers and called one with setContent and the other with setDeleteIntent. Interestingly, my problem has been fixed and now it works as I want it to. MediaPlayer is controlled in this way, it stops when you slide it to the right or left, and it stops again when the notification is clicked. Everything is as I want. The only problem is that WorkManager sometimes gets confused and can show notifications at different times. I do not know how to solve this ...