forked from organicmaps/organicmaps-tmp
[android] Added Null checking for location manager
This commit is contained in:
parent
e294e16550
commit
f58c1e0974
1 changed files with 7 additions and 1 deletions
|
@ -119,7 +119,7 @@ public class LocationUtils
|
|||
}
|
||||
}
|
||||
|
||||
public static void logAvailableProviders()
|
||||
private static void logAvailableProviders()
|
||||
{
|
||||
LocationManager locMngr = (LocationManager) MwmApplication.get().getSystemService(Context.LOCATION_SERVICE);
|
||||
List<String> providers = locMngr.getProviders(true);
|
||||
|
@ -141,6 +141,12 @@ public class LocationUtils
|
|||
{
|
||||
Context context = MwmApplication.get();
|
||||
LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
|
||||
if (locationManager == null)
|
||||
{
|
||||
LOGGER.e(TAG, "This device doesn't support the location service.");
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean networkEnabled = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
|
||||
boolean gpsEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
|
||||
LocationUtils.logAvailableProviders();
|
||||
|
|
Loading…
Add table
Reference in a new issue