Android 始终调用强制转换设备GoogleAppClient.onConnectionFailedListener
我很难调试为什么我与cast设备的连接总是失败,但在其他非我的应用程序中工作正常 我获得了对cast设备的引用,但在我自己的实现中,我无法使用以下方式连接到该设备:Android 始终调用强制转换设备GoogleAppClient.onConnectionFailedListener,android,chromecast,google-cast,Android,Chromecast,Google Cast,我很难调试为什么我与cast设备的连接总是失败,但在其他非我的应用程序中工作正常 我获得了对cast设备的引用,但在我自己的实现中,我无法使用以下方式连接到该设备: private void connectToCastDevice(CastDevice currentDevice) { // Create the CastOptions.Builder Cast.CastOptions apiOptionsBuilder = Cast.CastO
private void connectToCastDevice(CastDevice currentDevice) {
// Create the CastOptions.Builder
Cast.CastOptions apiOptionsBuilder = Cast.CastOptions.builder(currentDevice, mCastClientListener).build();
// If the GoogleApiClient is not null and is Connected
if((mGoogleApiClient != null))
{
// Disconnect from the Client
mGoogleApiClient.disconnect();
// Set the Client to null
mGoogleApiClient = null;
}
// Instantiate the GoogleApiClient Object
mGoogleApiClient = new GoogleApiClient.Builder(mContext)
.addApi(Cast.API, apiOptionsBuilder)
.addConnectionCallbacks(mConnectionCallbacks)
.addOnConnectionFailedListener(mConnectionFailedListener).build();
// Connect to the ApiClient
mGoogleApiClient.connect();
}
以下是我的日志对延迟更新的歉意:
07-29 22:28:49.608:I/MediaRouter(2888):取消选择当前路由,因为它不是
longerselectable:MediaRouter.RouteInfo{uniqueId=com.google.android.gms/.cast.media.CastMediaRouteProviderService:16f658a34d13c744277d3755727a7762,name=old-reliable,description=Chromecast,enabled=true,connecting=false,playbackType=1,playbackStream=-1,volumeHandling=0,volume=0,volumeMax=20,presentationDisplayId=-1,extras=Bundle[{com.google.android.gms.cast.EXTRA_cast_DEVICE=“old reliable”(16f658a34d13c744277d3755727a7762)},providerPackageName=com.google.android.gms}
这意味着什么?你怎么知道你没有连接?你是在真正的手机上测试的吗?日志文件显示了什么?我现在已经重新启动了我的设备,并且在启动应用程序时得到了!status.issucess()。是的,这是控制台中真正的设备设置。我应该使用setVerboseLoggingEnabled(true)?status.describeContents吗()将导致0您所指的是哪种状态?我在代码中看不到这一点,是的,打开详细日志记录并查看日志。因此,当调用I onConnected时,Bundle始终为null,详细日志记录似乎没有告诉我多少,我将尝试为onConnected()发布更多信息Bundle参数在几乎所有情况下都将为null(临时连接恢复情况除外),所以如果调用了onConnected,则表示您已连接。