-
-
Save pyadav/e72d3341d1e6842a57476af21377caba to your computer and use it in GitHub Desktop.
Check location enabled or not
This file contains hidden or 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