When I open activity 1 (Main/Launcher activity of the app), that includes MediaBrowser connection, MediaBrowser.subscribe
works ok (onChildrenLoaded
move MediaBrowserCompat.connect() from onStart() to onCreate(), and move MediaBrowserCompat.disconnect() from onStop() to onDestroy()
works for me.
MediaController Callback
didn't work. It seems for me as caused by the similar bug. So I have moved call to unsubscribe()
to onDestroy()
too, and everything works now.protected void onCreate(Bundle savedInstanceState) {
...
mediaBrowser = new MediaBrowserCompat(this, new ComponentName(this, AudioService.class),
connCallbacks,
null);
mediaBrowser.connect();
...
}
@Override
protected void onStart() {
super.onStart();
}
@Override
protected void onStop() {
super.onStop();
}
@Override
protected void onDestroy() {
super.onDestroy();
MediaControllerCompat cntrlr = MediaControllerCompat.getMediaController(this);
if(cntrlr != null) {
cntrlr.unregisterCallback(cntrlrCallback);
}
if(mediaBrowser.isConnected()) {
mediaBrowser.unsubscribe(mediaBrowser.getRoot());
mediaBrowser.disconnect();
}
}