views:

296

answers:

1

Hi,

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.

A: 

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

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