Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MediaBrowserServiceCompat methods

How do I access the public methods that I have defined (not the overridden ones) in the MediaBrowserServiceCompat from an activity?

Earlier I had used just the service, so I could bind it with the activity class and then access the methods easily.

Now since no binder is returned (onBind is not overriden in mediaBrowserService) , how can that be done?

(I have also read from ianblake's blog that mediaBrowserService is automatically bound...is that useful here?)

like image 468
V1 Kr Avatar asked Oct 24 '25 19:10

V1 Kr


1 Answers

This was the top-ranked Google search result but this stackoverflow answer actually provides the step to accomplish what is needed.

Edit: Steps copied from the link above

  1. Create a MediaControllerCompat from your MediaBrowserCompat instance, following the documentation
  2. Call sendCommand, passing in a command String which uniquely identifies your command (say, doMagic), any parameters you wish to pass to the method, and a ResultReceiver if you want a return value.
  3. In the MediaSessionCompat.Callback registered with your MediaBrowserServiceCompat, override onCommand() and handle the command (say, by calling doMagic).
like image 128
Korogba Avatar answered Oct 28 '25 02:10

Korogba