我希望代码检查手机中的GPS是否打开或关闭?
答案 0 :(得分:2)
try {
LocationProvider lp = LocationProvider.getInstance(null);
if (lp == null) {
//Device doesn't currently have GPS enabled
} else {
//Device has GPS enabled
}
} catch (LocationException le) {
//Device's GPS is currently permanently disabled
}
信用:aligf