0

Similar to this link

I would like to know it if possible to somehow track battery even when my application is not turned on? My main aspects would be: 1) To get when battery was charged last time and how many %(level) it had then. 2) How many %(level) battery has discharged from its last time being charged.

My goal is: calculate roughly maybe, everytime battery level goes down with 1%. calculate how long it took to drop 1% then look how much % their is left. and do this check every 1%? Then I will be able to calculate time that is left for this battery :) Any help will be appreciated. :)

Community
  • 1
  • 1
whiteLT
  • 338
  • 7
  • 21

1 Answers1

1

You can get all this data through the SDK:

http://developer.android.com/training/monitoring-device-state/battery-monitoring.html

Specifically the calculation comes down to what you store and how you use it. Also as for your time/date when it was last charged that comes down to storing that value persistently in your app's sharedpreferences or database (contextual usage depending).

JoxTraex
  • 13,423
  • 6
  • 32
  • 45
  • Ok, so far as I understand I just need to save data and then just interpret it. But how my app should know what changes are being made in device if it not turned on all the time? Or is my app still collecting info when it even not turned on? – whiteLT Feb 27 '13 at 12:01
  • That im not sure.. check you data as you receive it and see in what states you get the data. – JoxTraex Feb 27 '13 at 18:08
  • Or do I need a service to do that? – whiteLT Feb 27 '13 at 18:13