我试图了解此代码示例的工作方式:React/Redux links list
问题是尝试实例化MediaBrowserCompat时崩溃。 这是我在logcat中看到的错误: E / MediaBrowser:ComponentInfo {com.audible.application / com.audible.application.car.PremiumMediaBrowserService}的onConnectFailed
它与Spotify完美配合。
任何理论?
我还没有修改上面链接中的示例代码。这是我正在谈论的部分:
private void setupMedia() {
// Should now have a viable details.. connect to browser and service as needed.
if (mMediaAppDetails.componentName != null) {
mBrowser = new MediaBrowserCompat(this, mMediaAppDetails.componentName,
new MediaBrowserCompat.ConnectionCallback() {
@Override
public void onConnected() {
setupMediaController();
mBrowseMediaItemsAdapter.setRoot(mBrowser.getRoot());
}
@Override
public void onConnectionSuspended(){
//TODO(rasekh): shut down browser.
mBrowseMediaItemsAdapter.setRoot(null);
}
@Override
public void onConnectionFailed() {
showToastAndFinish(getString(
R.string.connection_failed_msg, mMediaAppDetails.appName));
}
}, null);
mBrowser.connect();
} else if (mMediaAppDetails.sessionToken != null) {
setupMediaController();
} else {
showToastAndFinish(getString(R.string.connection_failed_msg, mMediaAppDetails.appName));
}
}