接近警报触发时如何获取当前位置
我使用以下代码来确定邻近警报触发时的当前位置:
Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
if (location == null) {
location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
if (location == null) {
// We'll just write an empty location
location = new Location("");
}
}
当我查看返回的位置时,我在不应该收到警报的位置输入警报。我的印象是,由于接近警报内部轮询 GPS 和网络提供商(从而更新 LastKnownLocation),该代码将产生当前位置。这个假设正确吗?
I am using the following code to determine the current location when a proximity alert fires:
Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
if (location == null) {
location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
if (location == null) {
// We'll just write an empty location
location = new Location("");
}
}
When I look at the locations that I get back I get entering alerts in locations where I should't get them. I was under the impression since proximity alerts internally poll the GPS and network provider - thus updating the LastKnownLocation - that this code would yield the current location. Is this assumption correct?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我正在使用以下代码来确定当前位置及其工作情况。查看dis代码...
I am using the following code to determine the current location and its working too. Check out dis code...