We recently added a MediaBrowserService to our app that allows Android Auto to discover and play audio content via our app on the device. This works as expected.
By default, Wear picks up and displays our "Now Playing" notification, provides basic Play/Pause funtionality, and provides a "Browse" action which is clearly communicating with our MediaBrowserService.
I'm working on adding an actual Wear sub-app to our main app and I'd like to call our own MediaBrowserService just like the Wear OS does.
However, when I call mediaBrowser.connect(), the ConnectionCallback onConnectionFailed always fires. The connection never succeeds. Debugging on the primary app, I never see a call come in to our MediaBrowserService.
Here's the related code. Is it possible to use a MediaBrowser in this way to replicate the functionality that Wear itself is capable of? Unfortunately, ConnectionCallback provides no information whatsoever to help explain why the connection attempt failed.
MediaBrowser.ConnectionCallback callback = new MediaBrowser.ConnectionCallback() {
@Override
public void onConnected()
{
super.onConnected();
}
@Override
public void onConnectionFailed()
{
super.onConnectionFailed();
}
};
MediaBrowser mediaBrowser = new MediaBrowser(this, new ComponentName("main.app.package.name", "full.package.name.of.our.mediabrowserservice"), callback, null);
mediaBrowser.connect();
UPDATE
When I play audio in our app and the audio notification appears on the watch, I can see our MediaBrowserService start and the package calling "onGetRoot" is
com.google.android.wearable.app
I was assuming this was Wear OS itself but that seems to be the package name for the Android Wear app on the device. Somehow it is requesting and relaying the data to the watch and perhaps MediaBrowser simply doesn't work from an actual Wear app on the watch?
I see plenty of examples for using GoogleApiClient to communicate data between watch and phone. I was hoping to reuse our MediaBrowserService since Wear uses it by default. It seems this is not an option and I must use GoogleApiClient and a WearableListenerService if I want to have the Wear app request data from the handheld app.