Sorry, there isn't a way to do this.  The best you can do is query the
current battery level (which is part of a sticky broadcast so the last
reported value is always available).

On Mon, Dec 13, 2010 at 6:11 PM, Thomas Okken <[email protected]>wrote:

> I'm working on an app that needs to adapt its behavior to the current
> battery status. When there's plenty of juice left in the battery, it
> may perform certain tasks in a way that maximizes responsiveness, but
> also drains a lot of power, while in a low-battery situation, it
> should automatically adjust its behavior in a way that maximizes
> battery life, even if that makes certain tasks run more slowly.
>
> My question is this: I know how my app can be informed when the
> battery *starts* running low, by registering a BroadcastReceiver with
> a BATTERY_STATUS_LOW intent. I've implemented this, and I've verified
> that it works; at the exact moment that the OS pops up the low-battery
> warning, my app also receives the broadcast, and goes into low battery
> mode.
>
> So far, so good... But what can I do to find out if the battery was
> low before my app was even launched?
>
> It seems like the app never gets the BATTERY_STATUS_LOW intent message
> if the battery was low before the app was even launched. I can't seem
> to find an API that lets me query the battery status *right now*, i.e.
> without having to register a receiver that will only get notified when
> the battery status *changes*.
>
> Is there a way to find out *immediately* whether the battery status is
> "LOW" or "OKAY"?
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]<android-developers%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>



-- 
Dianne Hackborn
Android framework engineer
[email protected]

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to