How to check whether an android device has gps support or not?
i'm trying to write a method which checks the gps support of android device. Although having gps support on emulator, it always returns false. But when i try it on my android devices it returns true. What can be reaso开发者_JAVA百科n of that?
public boolean isGpsAvailable() {
PackageManager pm = this.getPackageManager();
if (pm.hasSystemFeature(PackageManager.FEATURE_LOCATION_GPS)) {
return true;
} else {
return false;
}
}
If you're using a LocationManager, you could use this method:
http://developer.android.com/reference/android/location/LocationManager.html#getAllProviders%28%29
Then look through all of the strings returned, and see if one is a GPS provider.
精彩评论