Showing posts with label programming on the move. Show all posts
Showing posts with label programming on the move. Show all posts

Monday, 6 February 2012

SL4A Scripting Languages for Android

In my hunt for programming capabilities on the Android, and some playing around with BeanShell I found something that worked very well.

I downloaded SL4A which is a scripting host for Android. It takes a bit of setting up, as you then need to install the BeanShell interpreter. However, from there I was able to automate a question I was wondering about.

The idea is simple, using a specific search term, can I get a feel for how much battery life people get from their handsets?

So after a bit of hacking at the script, I was able to simply searche for the handset name, and "battery lasts x days" where x was iterated.

The result:

HTC Wildfire battery days (1): 58
HTC Wildfire battery days (2): 199
HTC Wildfire battery days (3): 83
HTC Wildfire battery days (4): 8
HTC Desire battery days (1): 71
HTC Desire battery days (2): 943
HTC Desire battery days (3): 422
HTC Desire battery days (4): 7
Nexus One battery days (1): 4
Nexus One battery days (2): 240
Nexus One battery days (3): 444
Nexus One battery days (4): 0
Nexus S battery days (1): 37
Nexus S battery days (2): 237
Nexus S battery days (3): 72
Nexus S battery days (4): 3

My HTC Wildfire gets about 2 days, so that query technique feels like it has turned up some useful data.

And for those interested in the BeanShell script.

Tuesday, 17 January 2012

Programming on an Android device

A surprisingly rare subject to find on the Internet. The ability to code on your Android and be somewhat effective.

The main problem with programming on one of these platforms is the lack of compiler/runtime environment for the language you are interested in. My interests for example cover Java, C and a wiff of TCL. However trying to program any of these on the Android is a non starter from a native compilation point of view. At least at this present time of writing.

So what are the options? I recently discovered an app called Touchqode. A text editor aimed at coding, it supports various language syntax. This solves one of the problems with coding on a smart phone. The development environment.


The other part is how to compile the code. Two I thought of were:

  • Ideone.com
  • DropBox + Compile/Run/Test Daemon

Ideone.com


Ideaone.com is an online compilation/runtime environment. It allows you to paste code in and see the results of the code executing. It isn't really intended to run full projects, at least from what I can see. (I suspect logging in will provide you with a few more features).

As a starting point, this might be a valid option.

DropBox + Compile/Run/Test Daemon


The other option is to make use of the fact that DropBox is awesome. If you load and edit a file on your smart phone, that change will be transmitted to all other computers that run DropBox.

If you have a computer you leave on, say your work PC, then you could easily setup a daemon which watches for the changes in files in a certain folder, and executes a specific command storing the output in another file.

Then you would simply need to wait and then reopen the 'results' file to see what happened. Make some more changes, resave, and wait for the recompile.

If you wanted to go one stage further, you could setup a command/control signalling mechanism either via DropBox file changes, or via a distributed network like Twitter to provide signalling that the compile is complete.

Conclusion


The obvious point to make here is, you are not going to write a complete application in this fashion. An application with user interface is not a sensible objective, however, something that can produce meaningful output on the command line still covers a wide range of applications.

The other main usage that comes to mind is unit testing, which is an important task and can output entirely to the command line.