-
Notifications
You must be signed in to change notification settings - Fork 468
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
Documentation about media3 , Android 13 and dismissible foreground notification #211
Comments
If you are using The idea of the Media3 library is to smooth out the differences regarding API versions. So strictly speaking it should just work for you in the default configuration and you don't need to care about API levels yourself. If it doesn't work then please file a bug. So a first step is using Media3 on an Android 13 device and see how this works. You can use the session demo app for this if you haven't migrated your app to Media3 yet.
Like you say, there is a mini player for each active media session. The mini player can't be dismissed.
The mini player can't be dismissed. It is removed when you remove the notification with the session attached to it.
When playback is paused, the service is taken off the foreground and a notification is posted with the notification manager. The mini player is still not dismissible
There is a mini player that is not dismissible.
Not sure I understand and how this is different on Android 13 but you can call for instance
You can override |
I just kind of give up of restoring the state of my app from dead state with this dangling notification (e.g. When pausing a playback, killing the app, then going to play from notification). So I decided might be best that if I paused a playback, and when user dismiss the app, it should also kill that notification player. How do I override this behavior and just dismiss the notification? |
How are these two use cases related? Even if you do not implement playback resumption from BT you can keep your app playing in the background when the users exits the app. I'm not trying to convince you for one or the other UX option. My point is that stopping the service when the user dismisses the app is not related to support playback resumption from BT.. From the
Please also pay some attention to this comment. |
@marcbaechinger – We aim to provide the following UX for our users:
Currently, I'm facing challenges with achieving the first requirement. Based on your comments and observations of the app's behavior, it seems that achieving this may not be possible. I'm curious to understand the impact of setting Regarding the solution you provided with |
Upon conducting further testing, I have discovered that the "mediaController is not connected" issue occurs when the back button is pressed repeatedly to close all activities. It appears that in such cases, the |
This is based on a foreground service requiring a notification when running in the foreground. |
Shouldn't users have the ability to dismiss the notification and forcefully terminate the app from which the notification originated? I believe that displaying persistent notifications may result in users uninstalling our app and could have a negative impact on our brand reputation. Is there a version of I wonder how WhatsApp & YouTube do it. Both do it well and they don't show any notification at all. |
Not by the library. I agree that an app should be able to do this if it really wants to. With the current default implementation, I think you can do this by a custom action that is placed on the notification and tears down the service. you can also override Aside from that: Are you able to get an event from the OS notifying the the swipe gesture when the foeground notification is dismissed on all API levels? As far as I can tell this is not possible on the most recent API levels. If you find a system API that we can use, then it would make sense that we expose this API to apps. I think there isn't such an API that is available on all API levels though. If you can educate me about such an API being available, we can make this an enhancement to expose the API so you would be able to destroy the service yourself. I don't think we will implement the behavior described by you as a default.
These apps always have an activity in the foreground when they are playing. The default implementation of However, if you have an app that doesn't do background playback then you can solve this without a foreground service but instead always be bound to the service. That's a valid approach and should be comparably easy to implement. If you want to do this, then you can override |
Thank you, @marcbaechinger, for providing a prompt and detailed explanation. I appreciate your suggestion to try overriding the onUpdateNotification() method, and I will give it a try. |
@marcbaechinger, Isn't https://developer.android.com/reference/android/app/Notification#deleteIntent |
Another related issue is the race condition between the |
Just as a disclaimer: With the current version of the library, the app is responsible to terminate the service once playback has been started. We are thinking about stopping the service from library side for future version, but for now, the app needs to decide whether to stop the service in There are two approaches of behavior in Approach 1: Keep playing in the background when playing
Approach 2: Stop playback when app terminates
That's interesting. Can you explain the relationship between In my mental model the notification is related to the player state rather than calls to A better metric would probably be My understanding is that in any case you can do a
I can imagine this being true for some use cases on some API levels. I don't think this holds as a general statement though. For instance, when an app wants to continue playback in the background on an API level below 29, then I think the situation that we want to keep the service running even when no controller is connected against the session/service is quite common. If we would stop the service in this situation, the user wouldn't be happy because we stop the playback when the last controller disconnect, which is for instance when the app goes into the background and releases the controller. |
Hi, thanks for response. I use Pixel 6a with Android 13. Of course, I only try to stop the service and release the player if If One way to experience this broken notification is to move |
We have updated the guide pages on developer.android.com. Specifically these three pages are extended and adjusted to the newest release:
I'm closing this issue which is about documentation. @JureSencar If your case still is a problem, can you please file a new issue specifically around your case? |
Documentation about media3 , Android 13 and dismissible foreground notification
I recently came across this video about migration to Android 13
https://youtu.be/wBx3-ZObxY8?t=158
The new android 13 will be available soon and the new feature that it has is dismissible foreground notification , this is a critical feature for background music player apps . Although it has been mentioned the mediasession notifications are exempt from the new notification permissions there are few doubts that we have
#205
#175
A proper documentation will be helpful
PS: the primary objective of foreground service was to indicate a service is running, with the help of notification as mentioned here
https://developer.android.com/guide/components/foreground-services
Foreground services perform operations that are noticeable to the user.
Foreground services show a [status bar notification] so that users are actively aware that your app is performing a task in the foreground and is consuming system resources
so if the notification is dismissible how different does it become from a background service and if the service is "tied" to the notification how do we handle the closing of our service and the app, (should we use some thing similar to this )
https://stackoverflow.com/questions/6330200/how-to-quit-android-application-programmatically
or any other standard that android will prescribe.
The text was updated successfully, but these errors were encountered: