我要打电话给GoogleApiClient服务。第一次启动该服务时,将调用onConnected()。然后通过stopSelf()停止服务并重新启动,以便重新构建mGoogleApiClient (null):
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addApi(Nearby.CONNECTIONS_API)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
然后:
mGoogleApiClient.connect()
结果:
ConnectionResult{statusCode=UNKNOWN_ERROR_CODE(8050),NearbyDiscoveryService: onConnectionFailed ::resolution=null,message=null}
知道有什么问题吗?Google没有告诉任何错误代码8050 (与Android相关)!
发布于 2017-08-17 06:38:41
我刚刚发现了问题。在调用stopSelf()之前,我必须关闭GoogleApiClient的连接
//[...]
if( isDiscovering() ) {
stopDiscovering();
}
if (!isAdvertising()) {
getGoogleApiClient().disconnect();
stopSelf();
}
//[...]
https://stackoverflow.com/questions/45737881
复制