How can I determine programmatically the last time I charged my phone? What I'm looking for is something that in a TextView called time
shows me:
Last time on charge: 3h ago
and of course if is charging will be
Last time on charge: 0h ago
or something like this. I think I have to register an AlarmManager but I'm nit sure. I just want to create this estimate nothing more. How can do it?
I don't think android straight away provides an API for the last-charge time.
Alternatively, you could register for Broadcasts e.g.
and save the time whenever the charger is disconnected and use that in your app.