融合位置提供者似乎没有使用GPS接收器接收器、提供者、位置、GPS

由网友(愛過所以痛过)分享简介:安卓4.3摩托G,安卓4.4.2在Nexus 7 2012年,安卓4.4.2在Nexus 5,Android的工作室0.4。Android 4.3 on Moto G, Android 4.4.2 on Nexus 7 2012, Android 4.4.2 on Nexus 5. Android Studio 0....

安卓4.3摩托G,安卓4.4.2在Nexus 7 2012年,安卓4.4.2在Nexus 5,Android的工作室0.4。

Android 4.3 on Moto G, Android 4.4.2 on Nexus 7 2012, Android 4.4.2 on Nexus 5. Android Studio 0.4.

我不想接受定期位置更新,我只想得到一个精确的位置,当用户presses一个按钮。

I don't want to receive regular location updates, I just want an accurate location when the user presses a button.

我按照这个例子:https://developer.android.com/training/location/retrieve-current.html

在清单文件:

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

我检查播放业务可使用GooglePlayServicesUtil.isGooglePlayServicesAvailable

I check that Play Services are available using GooglePlayServicesUtil.isGooglePlayServicesAvailable

在主要活动:

//in activity onCreate method
mLocationClient = new LocationClient(this, this, this);

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

@Override
protected void onStop() {
    mLocationClient.disconnect();
    super.onStop();
}

//in button onclick method    
mCurrentLocation = mLocationClient.getLastLocation();

我没有SIM卡。如果我能无线上网的话,有时我得到一个准确的定位。其他时间mCurrentLocation为空。

I have no SIM card. If I enable Wifi then sometimes I get an accurate location. Other times mCurrentLocation is null.

如果我禁用无线然后mCurrentLocation总是空。

If I disable Wifi then mCurrentLocation is always null.

我在几个地点总是与天空一个明确的说法测试之外。我在每个位置等待了三分钟。

I am testing outside in several locations always with a clear view of the sky. I waited three minutes in each location.

我从来没有看到GPS图标在屏幕上方出现在Android通知栏上。

I never see the GPS icon appear on the Android notification bar at the top of the screen.

我有这些位置的设置:

I have these location settings:

一个GPS测试应用程序管理使用GPS成功地在室内使用Wi-Fi相同的设备禁用,因此GPS的工作:

A GPS Test app manages to use GPS successfully indoors on the same device with Wi-Fi disabled so GPS is working:

注册的位置更新,在https://developer.android.com/training/location/receive-location-updates.html,也不管用。注册方法从来没有所谓。

Registering for location updates, as at https://developer.android.com/training/location/receive-location-updates.html, doesn't work either. Registered method never called.

我是什么做错了吗?

推荐答案

我解决了它。问题是,让谷歌应用程序访问您的位置被关闭:

I solved it. The problem was that "Let Google apps access your location" was turned off:

当我打开它,我得到的GPS数据时,它的过我不知道。

When I turn it on I get GPS readings and when it's off I don't.

我已经离开它关闭的原因有两个:

I had left it off for two reasons:

我正在开发一个应用程序将用于许多设备在公司,我想最少手动配置是必要的。

I'm developing an app to be used to lots of devices at a company and I want minimum manual configuration to be necessary

该屏幕清楚地说:此设置只影响谷歌的应用程序。我知道,播放服务是谷歌软件,但我不认为谷歌所期望的最终用户理解。

The screen says clearly "This setting affects Google apps only." I know that Play Services is Google software but I didn't think Google would expect an end user to understand that.

然后,我得到了Android 4.4.2更新和位置设置页面发生了变化。看来,我可以有谷歌位置报告关闭,仍然可以从融合位置提供GPS数据:

Then I got the Android 4.4.2 update and the location settings page has changed. It appears that I can have Google Location Reporting turned off and still get GPS readings from the fused location provider:

所以,也许谷歌意识到,环境是混乱和完善它。无论哪种方式,我都节省了大量的时间,如果我有4.4.2几天前。

So maybe Google realised that the setting was confusing and improved it. Either way, I'd have saved a lot of time if I'd got 4.4.2 a few days ago.

阅读全文

相关推荐

最新文章