This simple code checks whether GPS in enabled in your android device or not.
If the GPS is not enabled the user is redirected to the settings page.
LocationManager service = (LocationManager) getSystemService(LOCATION_SERVICE); boolean enabled = service.isProviderEnabled(LocationManager.GPS_PROVIDER); // Check if enabled and if not send user to the GPS settings if (!enabled) { Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); startActivity(intent); }
Turn off the GPS on your device and running it will display this screen.
Please test GPS on the device because emulators don’t have GPS. But anyway you can simulate Longitude and Latitude which I will show in the coming posts.