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

Regarding removing the Notification from Notification bar #11016

Open
rohitgarg29 opened this issue Feb 24, 2023 · 2 comments
Open

Regarding removing the Notification from Notification bar #11016

rohitgarg29 opened this issue Feb 24, 2023 · 2 comments
Assignees
Labels

Comments

@rohitgarg29
Copy link

Hi Team,

I need to show one notification while User is locking the device. I am using PlayerNotificationManager and MediaSessionConnector for showing the notification and setting the controls like seekbar, play/pause. Everything is working fine. I need to remove the notification from the notificationbar when User is coming back from that fragment as I don't want to display it to user anymore.

I have tried to cancel the Notification with following ways:
notificationManager.setPlayer(null)
cancel (Notification_id)

Nothing seems to work, can you please suggest something?

Regards,
Rohit Garg

@marcbaechinger
Copy link
Contributor

marcbaechinger commented Feb 24, 2023

I'm pretty sure calling setPlayer(null) stops the notification.

I'd expect you don't need to interact with the NotificationManager directly, so if you say you are calling cancel (Notification_id) then I would guess there is a problem with the app code and I'd review this by debugging.

Nothing seems to work, can you please suggest something?

Make sure you don't use the notification with a foreground service. If the notifcation and its ID has been used to startForeground(notifcationId, notification) then the notification can't be removed.

If that does not help, remove all code that directly interacts with the NotifcationManager. That shouldn't be required and doing so may interfere with the expected behaviour.

Put a break point into PlayerNotificationManager.stopNotification() and see whether the code is executed as expected. Make sure that the notification ID has the expected value.

adb shell dumpsys notification shows the state of the notifcation. So you can try inspecting the output of this command and then review the properties of your notification.

@rohitgarg29
Copy link
Author

setplayer(null), yes it is stopping the notification but it is not removing the notification. PlayerNotificationManager.cancel(id) is not available in 2.17 version, so I am using NotificationManager.cancel(id). Was it introduced in later versions?? Then i might need to upgrade my libs.

There is no Service used to run it as there is no requirement to play the audio in background. I will try out the suggestions as well.

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

No branches or pull requests

2 participants