更新时间:2023-01-25 23:12:18
查看 位置提供者
.在不同情况下的一些设备上尝试此代码,我认为它应该可以工作:
Have a look at docs for Location Provider
. Try this code on a few devices in different situations and I think it should work:
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
}