You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Register correct MediaButtonReceiver in MediaSessionLegacyStub #314
Last MediaButtonReceiver: MBR {pi=PendingIntent{c9283b3: PendingIntentRecord{df4cd70 com.example.android.uamp.next startForegroundService}}, type=3
However, the pending intent is already cancelled by the the MediaSessionImpl when the session is released. This is wrong, instead the pending intent needs to be removed entierly.
instead, the MediaSessionLegacyStub should do:
When the session is created:
Check whether the app has a broadcast receiver for ACTION_MEDIA_BUTTON in the manifest. If this is the case this receiver should be used as the component and pending intent passed to the constructor of MediaSessionCompat.
If no app provider receiver is provided and the session is housed by a service, the pending intent is used as the mbr component and pending intent.
If not in a service, a new runtime broadcast receiver is used instead.
When the session is released:
Use mediaSessionCompat.setMediaButtonReceiver(null) unless the app has provided its own broadcast receiver in the manifest.
Note: An app can only be restarted by BT headset if:
A broadcast receiver for ACTION_MEDIA_BUTTON is registered in the manifest by the app developer. With this the app claims to be able to start playback when the service is started with a pending intent from BT headset.
Activity
marcbaechinger commentedon Apr 11, 2023
When running
The following pending intent is registered:
However, the pending intent is already cancelled by the the
MediaSessionImplwhen the session is released. This is wrong, instead the pending intent needs to be removed entierly.instead, the
MediaSessionLegacyStubshould do:When the session is created:
ACTION_MEDIA_BUTTONin the manifest. If this is the case this receiver should be used as the component and pending intent passed to the constructor ofMediaSessionCompat.When the session is released:
mediaSessionCompat.setMediaButtonReceiver(null)unless the app has provided its own broadcast receiver in the manifest.Note: An app can only be restarted by BT headset if:
ACTION_MEDIA_BUTTONis registered in the manifest by the app developer. With this the app claims to be able to start playback when the service is started with a pending intent from BT headset.A fix for this is in review internally.
Related documentation:
https://developer.android.com/guide/topics/media-apps/mediabuttons
Precedence for app provided media button receiver
Precedence for app provided media button receiver
marcbaechinger commentedon Apr 21, 2023
Closing as this is released with 1.0.1.