gpt4 book ai didi

android - 即使没有网络也会调用 GooglePlayServicesClient onConnected 回调

转载 作者:行者123 更新时间:2023-11-29 17:55:30 29 4
gpt4 key购买 nike

我正在编写一个使用 Google 定位服务的应用程序。据我了解,当我在 LocationClient 对象上调用 connect() 方法时,实现 GooglePlayServicesClient.ConnectionCallbacks 的对象应该接收onConnected() 回调仅当 LocationClient 成功连接到 Google 的定位服务时。

但是,问题是即使我的手机没有连接到互联网,我也会收到此回调。不知何故,系统一定认为 LocationClient 已成功连接到 Google 的位置服务,即使我的手机没有连接到互联网。

什么给了?

以下是相关的代码 fragment :

@Override
protected void onStart() {
super.onStart();
mLocationClient.connect();
}

@Override
public void onConnected(Bundle bundle) {
Toast.makeText(this, "Connected", Toast.LENGTH_SHORT).show();
}

最佳答案

onConnected 当您的应用程序成功连接到 Google Play 服务应用程序时调用回调方法。您无需连接到互联网即可接收 GPS 更新。

关于android - 即使没有网络也会调用 GooglePlayServicesClient onConnected 回调,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19748629/

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