Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
trivedirujuta
Posts: 528
Registered: ‎10-06-2009
My Device: 9800,BB Dev Alpha,z10 limited edition

battery_info_get_time_to_empty() doesn't return proper value

Hi,

 

I am trying to display the remaining time of battery's fully discharge.Below is my code

 

 

if (BPS_SUCCESS == battery_get_info(&info))

                  {

                    int timeToEmpty = battery_info_get_time_to_empty(info);

                    fprintf(stderr, "time lefttt: %d\n", battery_info_get_time_to_empty(info));

                  

                    if (timeToEmpty == BATTERY_TIME_NA)

                    {

                      qDebug() << "Battery is not being discharged right now\n";

                    }

                    else if (timeToEmpty == BPS_FAILURE)

                    {

                      qDebug() << "Failure obtaining time to discharge\n";

                    }

                    else

                    {

                      qDebug() << "Time to discharge is" << timeToEmpty << " minutes.\n";

                    }

 

                    battery_free_info(&info);

                  }

                  else

                  {

                    qDebug() << "Unable to get battery info\n";

                  }

 

 

I am getting 0 minutes every time.Can someone help?

 

Rujuta Trivedi
Please use plain text.
Developer
trivedirujuta
Posts: 528
Registered: ‎10-06-2009
My Device: 9800,BB Dev Alpha,z10 limited edition

Re: battery_info_get_time_to_empty() doesn't return proper value

Anyone who can help?

Rujuta Trivedi
Please use plain text.
Developer
zezke
Posts: 1,004
Registered: ‎12-12-2010
My Device: Z10 (red Limited Edition)

Re: battery_info_get_time_to_empty() doesn't return proper value

I would love to help, but I am deviceless. At least you got a free up!
-------------------------------------------
BlackBerry Certified Builder for Native Application Development -- Proud member of the Belgian BlackBerry Developer group
Samples: Park in Ghent
Feeling generous? Nominate me for BB Elite member!
Please use plain text.
Developer
trivedirujuta
Posts: 528
Registered: ‎10-06-2009
My Device: 9800,BB Dev Alpha,z10 limited edition

Re: battery_info_get_time_to_empty() doesn't return proper value

Anyone who can help?

 

The same code works for getting time remainig for charging battery(battery_info_get_time_to_full) but not for empty

Rujuta Trivedi
Please use plain text.
Developer
tanphat1412
Posts: 125
Registered: ‎11-06-2012
My Device: BlackBerry

Re: battery_info_get_time_to_empty() doesn't return proper value

Please use plain text.
Developer
trivedirujuta
Posts: 528
Registered: ‎10-06-2009
My Device: 9800,BB Dev Alpha,z10 limited edition

Re: battery_info_get_time_to_empty() doesn't return proper value

I have used code from the same post. It works for time to full but not fore time to empty

Rujuta Trivedi
Please use plain text.
Developer
zezke
Posts: 1,004
Registered: ‎12-12-2010
My Device: Z10 (red Limited Edition)

Re: battery_info_get_time_to_empty() doesn't return proper value

What kind of device are you using?

-------------------------------------------
BlackBerry Certified Builder for Native Application Development -- Proud member of the Belgian BlackBerry Developer group
Samples: Park in Ghent
Feeling generous? Nominate me for BB Elite member!
Please use plain text.
Developer
trivedirujuta
Posts: 528
Registered: ‎10-06-2009
My Device: 9800,BB Dev Alpha,z10 limited edition

Re: battery_info_get_time_to_empty() doesn't return proper value

Dev Alpha A. Will it work fine on z10?

Rujuta Trivedi
Please use plain text.
Developer
smiley
Posts: 1,475
Registered: ‎07-14-2008
My Device: Z10

Re: battery_info_get_time_to_empty() doesn't return proper value

I have report this bug months ago when I had the dev alpha.

 

The function always return incorrect value.

Please use plain text.
Developer
trivedirujuta
Posts: 528
Registered: ‎10-06-2009
My Device: 9800,BB Dev Alpha,z10 limited edition

Re: battery_info_get_time_to_empty() doesn't return proper value

Does it return true value on z10?

Rujuta Trivedi
Please use plain text.