I've recently updated one of my devices to Android 6.0 (API 23) and since doing so I've been unable to get location information in my application.
Quite simply, the issue is this:
locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
for (String providerName : locationManager.getProviders(false)) {
if (locationManager.isProviderEnabled(providerName)) {
activeProviders.add(providerName);
try {
locationManager.requestLocationUpdates(providerName, LOCATION_UPDATE_DELAY_MS, LOCATION_THRESHOLD_METERS, this);
} catch (SecurityException e) {
// TODO: Service not available, Handle This..
Toast.makeText(context, "Location Disabled", Toast.LENGTH_SHORT).show();
}
}
}
The application does request location permissions as it always has as well.
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
This works without any problem on android 4.4 KitKat (Galaxy Nexus), but returns an empty provider array on android 6.0 Marshmallow (Nexus 5). It also previously worked on this same Nexus 5 device running Lollipop 5.1.1.
Am I missing something obvious?