Is there a way to determine whether or not the Blackberry has a cable plugged in or not? (power/USB)
I have tried a number of things so far...
if(DeviceInfo.BSTAT_IS_USING_EXTERNAL_POWER > 0)
{
// Plugged in
// TODO : Do something
}else{
// Not plugged in
// TODO: Do something else
}
The else is apparently dead code, and this doesn't work at all.
I have however had some luck with the following:
if((DeviceInfo.getBatteryStatus() ^ DeviceInfo.BSTAT_IS_USING_EXTERNAL_POWER) != 0)
{
// Plugged in
// TODO : Do something
}else{
// Plugged in
// TODO : Do something else
}
Sadly though, it is only effective if the battery is at 100%. As soon as it drops below, it has the opposite effect.
The latter was compiled using a related issue on SO, however it does not have the desired results as suggested there.