Skip to main content

show battery status in app...?

6 replies [Last post]
mkant
Offline
Joined: 2010-02-03
Points: 0

Hello,

is there a not so complexe solution, to show the battery status in my app as per cent?

e.g. Battery status: 54 %.

Thank you.

Best regards,

Mathias

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Hinkmond Wong

phonemeadvanced@mobileandembedded.org wrote:
> Hello,
>
> is there a not so complexe solution, to show the battery status in my app as per cent?
>
> e.g. Battery status: 54 %.
>
> Thank you.
>
> Best regards,
>
>

Hi Mathias,

It depends which Java ME phone you are using. I believe with either a Nokia or Motorola phone, you can use a system property to get the battery level.

See:

http://stackoverflow.com/questions/944247/get-battery-status-from-j2me/9...

So, either this system property on Nokia phones:

| System.getProperty("com.nokia.mid.batterylevel");

or this system property on Motorola phones:

|| System.getProperty("batterylevel");

may give you the battery status you are looking for, then you would follow the example in the above URL to display the number in a MIDlet Form on the Display.

Hinkmond

|

---------------------------------------------------------------------
To unsubscribe, e-mail: advanced-unsubscribe@phoneme.dev.java.net
For additional commands, e-mail: advanced-help@phoneme.dev.java.net

mkant
Offline
Joined: 2010-02-03
Points: 0

I use a HP ipaq 214.

Do you know a way?

Thank you.

Best regards,

Mathias

Hinkmond Wong

phonemeadvanced@mobileandembedded.org wrote:
> I use a HP ipaq 214.
>
> Do you know a way?
>

Sorry, no. You might have to check with the HP forums or Web site to
find out.

Hinkmond

---------------------------------------------------------------------
To unsubscribe, e-mail: advanced-unsubscribe@phoneme.dev.java.net
For additional commands, e-mail: advanced-help@phoneme.dev.java.net

davyp
Offline
Joined: 2007-01-03
Points: 0

This device is running Windows Mobile 6 Classic. So it depends on which Java ME virtual
machine you are using and whether it offers a way to get to this information.

If you are developing an application with the phoneME Advanced stack or any other CDC based
virtual machine, you can create a native dll library for ARM that exposes access to battery
information to your Java application through JNI. This is more or less the native code you need:

int getBatteryStatus() {
int result = -1;
SYSTEM_POWER_STATUS_EX2 sps;

if (GetSystemPowerStatusEx2(&sps, sizeof(sps), TRUE))
result = (int)sps.BatteryLifePercent;

return result;
}

Davy

mkant
Offline
Joined: 2010-02-03
Points: 0

Hello,

thats sounds good, but I have no possibility to create this dll-File. (e.g. no Visual Studio...)

I had the same problem with exexcution of Files. At this time I think somebody make the dll File and I intgerate this in my app.

Mathias

davyp
Offline
Joined: 2007-01-03
Points: 0

I have used the eMbedded Visual c++ 4.0 suite to cross-compile for Windows Mobile/ARM, and
it still appears to be freely available:

http://www.microsoft.com/downloads/details.aspx?familyid=1dacdb3d-50d1-4...

Davy