Refactor isLocationServicesEnabled()

Revert to original implementation of the method
This commit is contained in:
Aditya-Sood 2019-08-12 13:07:25 +05:30
parent f071ad60b7
commit 5167e22466

View File

@ -318,20 +318,22 @@ public class LocalFileTransferActivity extends AppCompatActivity implements
private boolean isLocationServicesEnabled() {
LocationManager locationManager =
(LocationManager) getApplicationContext().getSystemService(Context.LOCATION_SERVICE);
boolean gps_enabled = false;
boolean network_enabled = false;
try {
return locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
gps_enabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
} catch (SecurityException | IllegalArgumentException ex) {
ex.printStackTrace();
}
try {
return locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
network_enabled = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
} catch (SecurityException | IllegalArgumentException ex) {
ex.printStackTrace();
}
return false;
return (gps_enabled || network_enabled);
}
private void requestEnableLocationServices() {