INNER CODE UNIT · Java
getDeviceLastKnownLocation
nic-delhi/AarogyaSetu_Android · app/src/main/java/nic/goi/aarogyasetu/CoronaApplication.java:61
public Location getDeviceLastKnownLocation() {
if(CorUtility.Companion.isLocationPermissionAvailable(CoronaApplication.getInstance()))
{
LocationManager mLocationManager = (LocationManager) getApplicationContext().getSystemService(LOCATION_SERVICE);
List<String> providers = mLocationManager.getProviders(true);
for (String provider : providers) {
try {
Location l = mLocationManager.getLastKnownLocation(provider);
if (l == null) {
continue;
}
if (lastKnownLocation == null || l.getAccuracy() > lastKnownLocation.getAccuracy()) {
lastKnownLocation = l;
}
}catch (SecurityException e){
}