gpt4 book ai didi

android - GoogleApiClient onConnectionSuspended ,我应该再次调用 mGoogleApiClient.connect() 吗?

转载 作者:IT老高 更新时间:2023-10-28 23:10:29 25 4
gpt4 key购买 nike

我在服务中使用 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 文档)中它说:

Applications should disable UI components that require the service, and wait for a call to onConnected(Bundle) to re-enable them.

但是这个对 onConnected 的调用将如何发生呢?我应该再次调用 mGoogleApiClient.connect() 吗?或者即使在连接暂停后 mGoogleApiClient 仍会继续尝试连接?

最佳答案

GoogleApiClient 将自动尝试重新连接。您无需再次调用 connect()

关于android - GoogleApiClient onConnectionSuspended ,我应该再次调用 mGoogleApiClient.connect() 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26056148/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com