Our app request update location with LocationClient and IntentService. Location doesn't update at all if user disable wifi in phone settings.
We tried to test app with PRIORITY_HIGH_ACCURACY and location updates when wifi disabled.
The same issue if user moving in the place where no wifi networks available.
I think correct behavior is use other phone sensors (like GPS) for update location if phone can not update location with wifi.
Steps to reproduce:
Start update location with pending intent. With parameters
LocationRequest request = LocationRequest.create() .setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY) .setInterval(5 * 60 * 1000) .setFastestInterval(60*1000) .setSmallestDisplacement(70);
Disable wifi in phone settings or go with phone in the country where no wifi networks available.
Tested on Android 4.4, 4.3, 4.1, 4.0, 2.3.3. (Nexus7, Nexus4, Samsung GS2, HTC Wildfire and others)
public class TrackerService extends IntentService {
private void startUpdateLocation() {
PendingIntent pendingIntent = PendingIntent.getService(getApplicationContext(),
0, new Intent(ACTION_LOCATION_UPDATED), 0);
LocationRequest request = LocationRequest.create()
.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY)
.setInterval(5 * 60 * 1000)
.setFastestInterval(60*1000)
.setSmallestDisplacement(70);
getLocationClient().requestLocationUpdates(request, pendingIntent);
Log.d(Utils.getMethodName(), "Location update started");
}
private LocationClient getLocationClient() {
if (mLocationClient != null && mLocationClient.isConnected()) return mLocationClient;
mLocationClient = new LocationClient(this,
new GooglePlayServicesClient.ConnectionCallbacks() {
@Override
public void onConnected(Bundle bundle) {
Log.d(Utils.getMethodName(), "Location client. Connected");
}
@Override
public void onDisconnected() {
Log.d(Utils.getMethodName(), "Location client. Disconnected");
}
},
new GooglePlayServicesClient.OnConnectionFailedListener() {
@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
throw new IllegalStateException("Failed connection to location manager " + connectionResult.toString());
}
}
);
mLocationClient.connect();
try {
while (mLocationClient.isConnecting()) {
Thread.sleep(200);
}
} catch (InterruptedException e) {
throw new IllegalStateException("Thread interrupted", e);
}
return mLocationClient;
}
}
I tried to send bug report https://code.google.com/p/android/issues/detail?id=63110
Developers of Android can't help.
Where can I report about bugs in Google Play Services?
Is it a bug in Google Play Services?
What work around could you offer?
We don't want use PRIORITY_HIGH_ACCURACY because it drain phone battery. Our application tracking phone location and it shouldn't depends from wifi settings and wifi networks availability.