Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fused location provider doesn't seem to use GPS receiver

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.

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

I have followed this example: https://developer.android.com/training/location/retrieve-current.html

In manifest file:

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

I check that Play Services are available using GooglePlayServicesUtil.isGooglePlayServicesAvailable

In main activity:

//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(); 

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

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.

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

I have these location settings: enter image description here

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

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

What am I doing wrong?

like image 542
cja Avatar asked Jan 09 '14 13:01

cja


People also ask

How accurate is fused location provider?

The accuracy values are typically more than 10 meters, while a third party GPS app (such as GPS test) typically reaches better accuracy if I wait long enough.

How does a fused location provider work?

The fused location provider manages the underlying location technologies, such as GPS and Wi-Fi, and provides a simple API that you can use to specify the required quality of service. For example, you can request the most accurate data available, or the best accuracy possible with no additional power consumption.

Can I disable fused location?

In the app select the System tab search for the service named Fused Location and disable it. Also search for the service group Google Play Services. Inside it there will be another Fused Location service.


1 Answers

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

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:

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

  2. 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.

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: enter image description here

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.

like image 170
cja Avatar answered Sep 30 '22 08:09

cja