Methond 1 is to check whether the GPS is on:
12345 | public boolean isGPSIsOn() { LocationManager locationManager = (LocationManager) mContext .getSystemService(Context.LOCATION_SERVICE); return locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);} |
Method 2 is to open GPS setting page in Android device:
123456789 | public void openGPSSettingPage() { Intent intent = new Intent(); intent.setAction(Settings.ACTION_LOCATION_SOURCE_SETTINGS); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); try { context.startActivity(intent); } catch (ActivityNotFoundException ex) { } } |
: https://gist.github.com/Viyu/9406327