在 Blackberry 开发中检查电池状态

发布于 2024-08-01 13:43:48 字数 405 浏览 1 评论 0原文

我正在为 8900 + 9000 Blackberry 开发应用程序。 在我的应用程序中,我需要检查电池是否连接到充电器,特别是车载充电器。

我使用以下方法来检查电池是否正在充电:

if (DeviceInfo.getBatteryStatus() & DeviceInfo.BSTAT_CHARGING) != 0){}

这工作正常,但如果电池已充满电,则这是错误的。 因此,我尝试检查 BSTAT_IS_USING_EXTERNAL_POWER 和 BSTAT_AC_CONTACTS ,看看它们中的任何一个是否为真,但如果电池充满电,它们都是假的。

我看不到任何其他可用的 BSTAT_ 值,有没有办法确定汽车是否已插入、是否充满电?

提前致谢。

I am developing an application for 8900 + 9000 Blackberry. In my application I need to check if the battery is connected to a charger, specifically an in-car charger.

I used the following to check if the battery is charging:

if (DeviceInfo.getBatteryStatus() & DeviceInfo.BSTAT_CHARGING) != 0){}

This works fine but if the battery is fully charged then this is false. So I tried checking BSTAT_IS_USING_EXTERNAL_POWER and BSTAT_AC_CONTACTS to see if either of them come as true but they are both false if battery fully charged.

I can't see any other BSTAT_ values that would work, is there a way to determine if the car is plugged in, full batter or not?

Thanks in advance.

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

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

发布评论

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

评论(1

赠我空喜 2024-08-08 13:43:48

正如 IPX Ares 建议的那样,我使用了 XOR 运算符而不是 &:

(DeviceInfo.getBatteryStatus() ^ DeviceInfo.BSTAT_CHARGING) == 0)

As IPX Ares suggested I used an XOR operator rather than &:

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