V1 Kr
V1 Kr

Reputation: 187

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

Upvotes: 4

Views: 1218

Answers (1)

Korogba
Korogba

Reputation: 115

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

Upvotes: 2

Related Questions