Android:在现实生活中 getLastKnownLocation(LocationManager.NETWORK_PROVIDER) 返回 null 的频率是多少?

发布于 2024-09-18 11:51:02 字数 145 浏览 3 评论 0原文

Android 用户是否有机会重置 NetworkProvider,使位置为空? 我想到了一个想法,即只有在第一次启动设备后才能将该位置设置为空。但谷歌也会立即检查位置以征求我的意见。

当然,我正在为这种罕见的情况实现默认位置。我只是想知道这种情况有多罕见。

Do the Android users have the chance to reset the NetworkProvider, so that the location will be null?
I came up with the idea, that its only possible to have that location null, after starting the device the very first time. But also than google will check the location right away for my opinion.

Sure, I'm implementing a default location for this rare case. I just want to know how seldom this case is.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

潦草背影 2024-09-25 11:51:02

当在“设置”> 中禁用该服务时,它返回“null”。位置和安全>通过网络定位

所以这种情况经常发生。

It returns 'null', when the Service is disabled in Settings > Location and Security > location through network

So that can happen quite often.

南渊 2024-09-25 11:51:02

取决于用户连接互联网的频率。

小区 ID 必须转换为坐标,据我所知,有一个缓存,即使在离线状态下,它也会记住已经转换的小区 ID,但在新的小区 ID 上,它不会为您提供位置更新,直到手机不更新为止。连接到互联网。

无论如何,您始终需要检查该位置的日期,因为它可能已经过时了。尤其是在您将手机设置为飞行模式并前往世界其他地方之后。

Depends how frequently connects the user to the Internet.

The cell ids have to be translated to a coordinate, and as I know there is a cache, it will remember even when offline the cell ids already translated, but on new ones, it won't give you location updates until the phone it's not connected to Internet.

Anyway, you always needs to check the date of the location, as it might be outdated. Especially after you put your phone in airplane mode and travel to the other part of the world.

丶视觉 2024-09-25 11:51:02

在我的测试中,我发现它经常为空。没有用户告诉的情况下,没有多少东西会消耗 GPS。但 getLastKnownLocation 的问题是它可能非常过时。因此,即使它不为空,它也可能是几个小时甚至几天前的

In my testing I've found it's null fairly often. Not a lot of things consume the GPS without the user telling them to. But the problem with getLastKnownLocation is that it can be extremely out of date. So even if it's not null, it could be hours or even days old

仙气飘飘 2024-09-25 11:51:02

这可能还取决于您轮询的频率。
也就是说,如果您不经常检查它,它可能会设置为 null 并在那里停留一段时间。

locationManager.requestLocationUpdates(provider, minTime, minDistance,
这个);

我借用了一个项目作为 mapActivity 项目的骨架。它一直返回 null(使用 GPS 提供程序),直到我插入 requestLocationUpdates() 调用。

It will probably also depend on how often you are polling it.
That is, it could get set to null and stay there a while if you're not checking it frequently.

locationManager.requestLocationUpdates(provider, minTime, minDistance,
this);

I had borrowed a project as a skeleton for a mapActivity project. It was return null all the time (with a gps provider) until i inserted the requestLocationUpdates() call.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文