1

I would like to maintain a central list of the battery status of my devices. For my Linux laptops, I will write a small shell script that reads the battery information from the kernel and uploads it to my webserver.

I have no idea how to do this for Android devices, though. Basically I would like them to open http://example.com/tracker.php?id=cell&battery=0.67 every 30 minutes or so.

Is there an app that can do that? Although I have never programmed on Android yet, I have experience with Java and Linux. Is it possible to program something like that with reasonable effort?

1

There's a tool on Google Play called Batman, which collects battery status information in the background and stores it into a CSV file on SDCard. That done, you could use sync tools like e.g. FolderSync to have the file uploaded to your Linux machine in regular intervals, where you can have it processed by any tool you prefer.

Another variant (a little more tricky) could be using Tasker to create the data: Tasker offers the variable %BATT to give the current battery level in percent. It also supports things like HTTP_POST, so you could have Tasker post the current battery level in fixed intervals, and let your server do the rest (see the Tasker UserGuide for details).

Note: Tasker doesn't come for free, it's about 5 bucks. But you can download a free 7-day trial at the homepage for testing.

  • Batman is too slow for my purpose, I would like to know the current battery status. Tasker seems to be able to do this. Working on that myself will probably take more time than 3 €. Although I am a little uneasy with all the permissions that app wants … – Martin Ueding Jul 15 '13 at 14:28
  • I'm using Tasker for years now. I also use LBE to supervise permissions. So I can tell you Tasker did never ever abuse any of those permissions: not a single time something turned up in the logs. Of course I cannot speak for future versions, but in my eyes it seems a trustable app/dev. – Izzy Jul 15 '13 at 14:41
1

You can also write a script shell for Android. You just need an app like Script Manager that can run your script periodically.

You can read value from the kernel like on a "vanilla" Linux : the actual battery capacity is stored in /sys/class/power_supply/battery/capacity.

  • In the Script Manager Console, I do not have either wget nor curl, so I am not sure whether I can send a HTTP request from that. – Martin Ueding Jul 15 '13 at 14:27
0

I don't know of an app that can do that, but it would be easy enough to write one if you already know Java. You can get started with programming Android by reading the guides and documentation on the official site for Android Developers.

Do remember that once you've started programming, you should ask questions about that on our sister site Stack Overflow, which has a lively community of Android programmers. This site is for questions written from a user's point-of-view only.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.