【发布时间】:2014-11-21 06:19:23
【问题描述】:
我在服务中使用 GoogleApiClient 来请求融合位置更新。每件事都正常工作,但有时连接被暂停并调用 onConnectionSuspended。
@Override
public void onCreate() {
...
mGoogleApiClient = new GoogleApiClient.Builder(this) // this is a Context
.addApi(LocationServices.API)
.addConnectionCallbacks(this) // this is a [GoogleApiClient.ConnectionCallbacks][1]
.addOnConnectionFailedListener(this) //
.build();
mGoogleApiClient.connect();
...
}
@Override
public void onConnectionSuspended(int arg0) {
// what should i do here ? should i call mGoogleApiClient.connect() again ? ?
}
在上面的链接(ConnectionCallback 文档)中它说:
应用程序应禁用需要该服务的 UI 组件,并等待调用 onConnected(Bundle) 以重新启用它们。
但是这个对 onConnected 的调用将如何发生呢?我应该再次调用 mGoogleApiClient.connect() 吗?还是 mGoogleApiClient 即使在连接暂停后仍会继续尝试连接?
【问题讨论】:
标签: android google-play-services google-api-client