2

我正在使用谷歌附近的连接A​​PI的Android项目。一切都很好。我可以正确连接多个设备。谷歌附近的连接A​​PI - 不幸的播放服务停止

唯一的问题是如果mGoogleApiClient.disconnect();在任何情况下调用"Unfortunately google play service stopped"此警报出现。

我也试过Nearby.Connections.disconnectFromEndpoint(mGoogleApiClient, remoteEndpointId);Nearby.Connections.stopAllEndpoints(mGoogleApiClient);断开连接。但是同样的事情发生了。

即使在出现stop discoverystop advertising方法时也会出现此警报。这不是崩溃,我没有在Log上发现任何错误。

我初始化api客户端,并将覆盖方法设置为文档。 Start advertisingstart discovery方法也来自文档。

在我的gradle中我使用了compile 'com.google.android.gms:play-services-nearby:10.0.1'

然后,可能是什么问题。请帮助我,并提前致谢。

+0

从这[文件](https://developers.google.com/nearby/connections/android/get-started),您可以断开客户一旦你的游戏不再需要访问此服务。在您的活动的onStart()中连接GoogleApiClient,并在onStop()中断开连接。尝试检查此[教程]的断开连接部分(https://code.tutsplus.com/tutorials/google-play-services-using-the-nearby-connections-api--cms-24534)。 – KENdi

+0

Hi @ bhoot4242,你找到解决方案吗?对我来说,只有当我打电话给'Nearby.Connections.stopDiscovery(mGoogleApiClient,service_id)时才会发生;' – trinity420

回答

0

放的地方要断开此条件:

if (mGoogleApiClient != null && mGoogleApiClient.isConnected()) { 
      mGoogleApiClient.disconnect();} 
+0

不能正常工作.... – bhoot4242

相关问题