3

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?)

V1 Kr
  • 177
  • 1
  • 3
  • 18

1 Answers1

1

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).
Korogba
  • 105
  • 9
  • While this link might provide the right answer, it is always advised to provide some explanation and examples relevant to the question asked. Please check here on how to structure a good answer https://stackoverflow.com/help/how-to-answer – kosnik Jul 03 '18 at 16:48