Created
November 22, 2015 09:49
-
-
Save guptasanchit90/9eeaa1c09b2a5e651929 to your computer and use it in GitHub Desktop.
Check location enabled or not
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LocationHelper{ | |
public static boolean isLocationEnabled(Context context) { | |
LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); | |
// Check GPS status | |
boolean isGPSEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER); | |
// Check network status | |
boolean isNetworkEnabled = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER); | |
if (!isGPSEnabled && !isNetworkEnabled) { | |
return false; | |
} | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment