检查电池状态在黑莓开发 [英] Checking Battery Status in Blackberry development
问题描述
我开发了8900 + 9000黑莓的应用程序。在我的应用程序需要检查电池是否连接到充电器,特别是在车载充电器。
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){}
这工作正常,但如果电池完全充电则是假的。所以,我想检查 BSTAT_IS_USING_EXTERNAL_POWER和BSTAT_AC_CONTACTS
来看看其中一方来作为真实的,但它们都是假的,如果电池完全充电。
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.
我看不到任何其他BSTAT_值,将工作,有没有一种方法来确定汽车是否插好,全连击与否?
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?
在此先感谢。
推荐答案
由于IPX战神建议我使用的XOR运算符,而不是与放大器;
As IPX Ares suggested I used an XOR operator rather than &:
(DeviceInfo.getBatteryStatus() ^ DeviceInfo.BSTAT_CHARGING) == 0)
这篇关于检查电池状态在黑莓开发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!