Checking Battery Status in Blackberry development

感情迁移 提交于 2019-12-23 17:18:59

问题


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.


回答1:


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

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


来源:https://stackoverflow.com/questions/1266449/checking-battery-status-in-blackberry-development

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!