How to Check whether is GPS is enabled in your android device?

By | June 3, 2012

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.

GPS

Website Pin Facebook Twitter Myspace Friendfeed Technorati del.icio.us Digg Google StumbleUpon Premium Responsive

Leave a Reply

Your email address will not be published. Required fields are marked *