Open DiegoPinedoEscribano opened 2 years ago
It's a shame that this wasn't addressed one year ago when Android 12 was introduced. Is Google really unaware of this or are they just ignoring the consequences their bad API decisions have on apps? I really want to know how to solve this problem. I mean, they force developers to target the newest API levels and don't provide help on how to address such problems.
And btw, I think this doesn't relate to the Google Assistant because I have seen such crashes on devices where Google services are not available at all. I don't know how to reproduce it locally, but it's a fact that this crash happens on production apps.
It's a shame that this wasn't addressed one year ago when Android 12 was introduced. Is Google really unaware of this or are they just ignoring the consequences their bad API decisions have on apps? I really want to know how to solve this problem. I mean, they force developers to target the newest API levels and don't provide help on how to address such problems.
And btw, I think this doesn't relate to the Google Assistant because I have seen such crashes on devices where Google services are not available at all. I don't know how to reproduce it locally, but it's a fact that this crash happens on production apps.
We have opened an issue on their Issue Tracker in case you wanna also follow that one: https://issuetracker.google.com/u/1/issues/235172948
Also having this issue on one of our apps. I came here to see how Google solves the problem, only to find ... they haven't.
Any updates on this? We're also waiting for a solution
I think the issue come from this line in Music Service :
if (!playWhenReady) {
// If playback is paused we remove the foreground state which allows the
// notification to be dismissed. An alternative would be to provide a
// "close" button in the notification which stops playback and clears
// the notification.
stopForeground(false)
isForegroundService = false
}
The problem is that notification can't be dismissed since Android 10 with a foreground service, so the team disable the foreground when the media is paused. But as you explained you try to resume with the app is in background and so the service tries to be in foreground again, and the ForegroundServiceStartNotAllowedException happens. A hotfix could be to provide the "close button" and remove this part of the code. Of course, when the notification is dismissed you have to stop/destroy the service. Also the boolean isForegroundService is not really a good solution, Android should provide a listener for the state of the service.
The safest way is to ask the service to be in foreground not inside the service but in an activity/fragment inside your app. If your app is in background you could use AlarmManager to wake up your phone and go to your application.
Any Update
Hello, Please post an update on this issue. Thank you
The UAMP app crashes when trying to resume the playback session using the Google Assistant if the target and compile sdk is 31 or above
Steps to reproduce it:
Does the UAMP project still needs to be updated to comply with the latest restrictions around Foreground Services introduced in API 31 ? If this is the case, do you have any idea on when this would happen?
Is it possible that the problem is within the Google Assistant app?