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, in particular to a car charger.

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

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

This works great, but if the battery is fully charged, this is not true. So I tried checking BSTAT_IS_USING_EXTERNAL_POWER and BSTAT_AC_CONTACTS to make sure either of them is true, but they are both false if the battery is fully charged.

I do not see any other BSTAT_ values ​​that will work, is there a way to determine if the car is connected, full dough or not?

Thanks in advance.

+3
source share
1 answer

As IPX Ares suggested, I used the XOR operator, not &:

 (DeviceInfo.getBatteryStatus() ^ DeviceInfo.BSTAT_CHARGING) == 0) 
+1
source

Source: https://habr.com/ru/post/1434399/


All Articles