tags:

views:

47

answers:

2

Hi,

I'd like to know if there is a way to get the elapsed time since the phone was unplugged from AC supply. I know that I can register a receiver to catch battery events - but this just works if my service is running already when the status changes.

In my case I assume that the application is started when the AC supply was already plugged out before and I then want to retrieve the time

thanks in advance, cheers

Martin

+1  A: 

JuicePlotter does this somehow (http://latedroid.com/juiceplotter), it graphs battery events from before the app was started, or even installed. I don't know how it works, but it would be a good place to do some research.

fredley
I think it just does this when the service was already running in the background - if the app is started initially it also doesn't seem to have the information. But a nice app, by the way :)
Martin
A: 

looks like there's no way to figure out

Martin
Of course it's possible. What's wrong with using broadcast receivers? Your app does *not* need to be running before receiving a broadcast. Also, the pre-installed Battery Usage app shows this value, so have a look at its source code.
Christopher
I did, but it uses functionality which is not provided by the APIhttp://tinyurl.com/BatteryInfo-java
Martin