views:

102

answers:

2

Hi, do the mobile phones have an API function or something like that which could be called by a phone application to figure out whether the phone is currently charging or is on battery?

I guess that if there is such a function at all, it would have a different name on each mobile OS, so if anybody could name those function names and the OS, that would be great.

many thx

A: 

Nokia's implementation of Java ME has an API function to check the battery level. More generally, Java ME has the "Sensor API" (which is highly implementation-specific) that exposes sensors such as the charger state, accelerometer(s), etc.

Dmitry Brant
A: 

On the RIM BlackBerry line of devices, this can be done by using the net.rim.device.api.system.DeviceInfo class; specifically, the getBatteryStatus() static method of that class which returns a bitfield of flags related to the battery state on the device. The bitfield contains various flags that indicate whether the device is being charged or is running on battery power (among other things).

Andrey Butov