[android] Added Null checking for location manager

This commit is contained in:
alexzatsepin 2017-02-13 13:21:36 +03:00
parent e294e16550
commit f58c1e0974

View file

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