检查 Google Nearby 是否已被允许

Check if Google Nearby is already allowed

有什么方法可以验证 Google 附近的 API 是否已经获得授权?
方法 enableAutoManage() 自动执行所有操作,因此,它不会' 帮助,我想使用 publish()subscribe() 只有在我已经获得许可的情况下,否则什么都不做。 有什么想法吗?

如果您没有权限,GoogleApiClient.connect() 将失败。

请参阅以下 link 中的 "Handle errors",了解如何处理该错误并请求用户许可或直接失败。

详情请看下面 https://developers.google.com/nearby/messages/android/user-consent