Android icon indicating copy to clipboard operation
Android copied to clipboard

Notification won't disappear

Open cornflakes opened this issue 6 years ago • 3 comments

When playing music and casting to a Chromecast device. When done playing the notification doesn't disappear and it nessesary to force close the app to make it go away.

cornflakes avatar Jan 17 '20 18:01 cornflakes

yes I know about this bug, unfortunately, I don't have time to solve it

mohamedebrahim96 avatar Jan 19 '20 04:01 mohamedebrahim96

Do you have any insights into what is causing the bug. Cause I might have the time 😉

cornflakes avatar Jan 19 '20 06:01 cornflakes

Ensure that you are using MediaSessionCompat to manage media playback in your app.

Override onStop(): Override the onStop() method in your activity or service where media playback occurs. Inside this method, stop playback and release the media session. Also, cancel the notification associated with the media session.

Here's a code snippet demonstrating how you can handle the onStop() method:

Override this methiod protected void onStop() { super.onStop(); if (mediaSession != null) { mediaSession.setActive(false); mediaSession.release(); } // Cancel the notification NotificationManagerCompat.from(this).cancel(notificationId); }

Replace mediaSession with your actual MediaSessionCompat object and notificationId with the ID of the notification you want to cancel

please check is it working for you

FaisalShabbir007 avatar Mar 26 '24 20:03 FaisalShabbir007