I use this code to check if GPS is enabled to display a dialog:
LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
boolean GPSEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
But it only works until version 19 if I'm not mistaken, I'd like to implement it to work on all versions of android, but I could not, somebody give me that help ai, vlw!