在 BlackBerry 上,如果 GPS 服务选项设置为“位置关闭”,则 LocationProvider 为 null

发布于 2024-09-13 07:34:59 字数 787 浏览 2 评论 0原文

在此 线程 MSohm 说“GPS 服务选项不会打开或关闭 GPS”。这意味着,如果设备具有内置 GPS 接收器,则

LocationProvider provider = LocationProvider.getInstance(null);

无论 GPS 服务选项如何,此类代码都不应返回 null

但是,如果我在 Curve 8310 (4.5.0) 和 Storm 9530 (4.7.0) 模拟器(两者都有内置 GPS 接收器)上尝试上述代码,那么如果 GPS 服务我得到 null选项设置为位置关闭。如果我将 GPS 服务选项更改为位置ON,那么我会得到一个非空的 LocationProvider,然后我就能够获取定位等。

这是模拟器的错误吗?谁能说这在真实设备上如何工作?

更新:

我刚刚得到了在真实设备(Storm)上测试的结果。令人惊讶的是,真实设备的行为与我在模拟器上得到的相同。我很困惑。 MSohm 表示“GPS 服务选项不会打开或关闭 GPS”,但看起来它确实可以打开/关闭 GPS。有人可以发表意见吗?

In this thread MSohm says "The GPS Services option does not toggle GPS on or off". This means that if a device has a built-in GPS receiver, then the code like this

LocationProvider provider = LocationProvider.getInstance(null);

should never return null regardless of GPS Services option.

But if I try the above code on both Curve 8310 (4.5.0) and Storm 9530 (4.7.0) simulators (both have a built-in GPS receiver), then i get null if GPS Services option is set to Location OFF. If I change GPS Services option to Location ON, then I get a non-null LocationProvider and I am able then to get locatoin, etc.

Is this a bug of simulators? Can anyone say how this would work on real device?

UPDATE:

I just got the results of testing on real device (Storm). Surprisingly, real device behaviour is the same I got on simulator. I am confused. MSohm said "The GPS Services option does not toggle GPS on or off", but looks like it DOES toggle GPS on/off. Could anyone give any comments?

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

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

发布评论

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

评论(1

雨轻弹 2024-09-20 07:34:59

我的经验告诉我,这不是错误。

您实际上可以在 GPS 选项下的 Blackberry 选项中打开和关闭位置。

我建议的是,在声明 LocationProvider 之后检查它是否为空。如果为空,则向用户发送一条消息,告诉他 GPS 位置已关闭,必须先将其打开才能使用 GPS。

您还可以告诉他在哪里更改此设置。

您在真实设备上会得到相同的行为,所以我认为这是最好的方法。

我在 Curve 8530 上对此进行了测试。

请记住,运行模拟器时,您必须在模拟器的窗口菜单中启用 GPS,这可能是您在模拟器上获得空 LocationProvier 的原因

My experience tells me that this is no bug

You can actually toggle the location on and off at the Blackberry options, under the GPS options.

What I would recommend is, after declaring the LocationProvider checking if it's null. If it's null, send a message to the user telling him that the GPS location is turned off and that he has to turn it on first in order to use the GPS.

You could also tell him where to change this settings.

You get the same behaviour on real devices so I think this is the best approach.

I tested this on a Curve 8530.

Keep in mind that, when running a simulator, you have to enable GPS in the simulator's window menu, that could be the reason on why you're getting a null LocationProvier at the simulator

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