Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notification won't disappear #4

Open
cornflakes opened this issue Jan 17, 2020 · 3 comments
Open

Notification won't disappear #4

cornflakes opened this issue Jan 17, 2020 · 3 comments

Comments

@cornflakes
Copy link

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.

@mohamedebrahim96
Copy link
Member

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

@cornflakes
Copy link
Author

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

@FaisalShabbir007
Copy link

FaisalShabbir007 commented Mar 26, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants