问题
I am developing an app in which I have to check programmatically if gps is enabled or not for locations in phone? How do I find this?
回答1:
if (!LocationInfo.isLocationOn()) {
try {
LocationInfo.setLocationOn();
} catch (ControlledAccessException cae) {
// You don't have the rights to enable GPS programatically.
// You might want to prompt the user for it.
}
}
You might also want to have a look at the following functions:
- LocationInfo.isLocationSourceAvailable(int mode) - Determines if a specific location source is available to provide location information.
- LocationInfo.isLocationSourceSupported(int mode) - Determines if a specific location source is currently supported on the device.
gl
回答2:
All new BB have on device GPS. You just need to make sure it is set correctly.
First make sure you set GPS Data Source == Device GPS in the Options->Advanced Options app.
来源:https://stackoverflow.com/questions/4632907/check-if-blackberry-gps-is-enabled