John Smith John Smith - 6 months ago 125
Android Question

Looking for an example of the new Android API setMediaButtonReceiver

Currently I am using


but this is now deprecated in 5.0 and replaced by
. There are 5 links in Google all pointing to

Has anyone used this yet? If so can you provide an example?


Check this page: It is a rather large example of the complete flow.Here one of the most relevant parts

Set a pending intent for your media button receiver to allow restarting playback after the session has been stopped. If your app is started in this way an android.content.Intent.ACTION_MEDIA_BUTTON intent will be sent via the pending intent.

Parameters: nullmbr The to send the media button event to.

     public void More ...setMediaButtonReceiver(@Nullable PendingIntent mbr) {
         try {
         } catch (RemoteException e) {
   , "Failure in setMediaButtonReceiver.", e);