当前位置: 动力学知识库 > 问答 > 编程问答 >

java me - Checking Battery Status in Blackberry development

问题描述:

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.

网友答案:

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

(DeviceInfo.getBatteryStatus() ^ DeviceInfo.BSTAT_CHARGING) == 0)
分享给朋友:
您可能感兴趣的文章:
随机阅读: