【发布时间】:2015-10-31 19:33:20
【问题描述】:
我在启动后注册我的应用程序以接收位置更新。我的引导接收器正在启动一个进行初始化的服务:
@Override
protected void onHandleIntent(Intent intent) {
GoogleApiClient client = _googleApiBuilder.get()
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(LocationServices.API)
.build();
client.connect();
}
有时在onConnected 回调方法中,我收到异常指示,我尚未连接。经过一些研究,我遇到了这个 - GoogleApiClient is throwing "GoogleApiClient is not connected yet" AFTER onConnected function getting called
这让我想,我初始化 google api 的方式是否正确?例如我应该在服务中初始化它吗?
在后台执行此操作的建议方法是什么?
【问题讨论】:
标签: android google-maps google-api google-api-client