Skip to content

Instantly share code, notes, and snippets.

View rodrigohenriques's full-sized avatar

Rodrigo Henriques rodrigohenriques

View GitHub Profile
@lalbuquerque
lalbuquerque / LocationHandler
Last active April 22, 2016 16:08
Try to get location by GPS first and then, if it is disabled, by Network
private Location getLocation(){
long MIN_DISTANCE_CHANGE_FOR_UPDATES = 10L;
long MIN_TIME_BW_UPDATES = 1;
Location location;
try {
mLocationManager = (LocationManager) mContext.getSystemService(Context.LOCATION_SERVICE);
boolean isGPSEnabled = mLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);