The other day I discovered an app available for Android devices called Tasker, which has been around for awhile and has generated quite it's own little corner of the Internet dedicated to swapping tasks, procedures, profiles and scripts.

It's an easy entry point into programming your phone to do things when certain conditions are met. It allows you to firstly set up 'Profiles' - that are conditions or events that Tasker waits and checks for, onto which you can attach 'Tasks', which will be executed when the Profile is triggered. Examples for Profiles include things like receiving a text message, turning on your phone, battery power falling below 10%, connecting to a WiFi network, or even physically entering a certain zone specified using your various location tools (like GPS).

The Tasks are then down to you, and your imagination, to conceptualise and then realise (if possible... there are a few niggling limitations, especially if you haven't 'rooted' your phone). A quick google will show you some seriously ingenious hacks to make life easier, as well as some pretty hilariously contrived 'contigency' profiles such as this one from reddit:
"I have a profile setup so whenever anyone texts me on my t-mobile number (I use google voice as a main line) with a certain phrase it will
  1. mute notifications, max media volume
  2. automatically lock the phone
  3. put a pin on it (I usually have swipe to unlock)
  4. turn on GPS, wait until gps lock, then send a text to the number who originally texted the phone as well as my gvoice number with the phone's location, location speed, accuracy of location, and battery life
  5. play an edited audio clip of the phone scene from 'taken'
  6. repeatedly send texts every 20 seconds about location stats for half an hour
Another one is shaking my phone to turn on the torch"
The afterthought there is great. But you get the idea - you can have your phone discreetly text back it's GPS location upon receiving a certain passphrase (to the number that sent it), or even wake up your PC when you enter your house and have it greet you with Spotify playing a certain riddim. Actually the inverse of that is more sensible - have your phone send an HTTP GET to your home network to put all machines to sleep when you lose connection with your home WiFi network and are a certain distance from your house.

After some playing around, I started going through the various 'sensors' that you can access on the phone - mine's a Galaxy S3, and there's loads!

There's obviously...

  • GPS (Longitude, Latitude)

then there's:
  • Altitude (GPS + barometer)
  • Pressure (barometer)
  • Magnetic field (this one is amazing! See below)
  • Light sensor (standard one from front camera)
  • Proximity Sensor (how far an object is from the front camera)
  • Orientation (accelerometer + gyroscopes etc) 

The magnetic field sensor is jokes! You can set it to scan and just walk around the house pointing it at things (note the sensor is in the base of the phone, and as magnetic fields exist along field lines, the reading will depend on the orientation of the device) - it increases where there are electric cables in the walls etc. so you could totally use it for not drilling through power cables if you're doing a spot of DIY.

The highest reading I could get were my speakers (not too surprising when you think about it). Ambient levels are about 30mT, inside the oven (closest I could get to a Faraday cage) was 4mT, next to my speakers was 2500mT haha.

Anyway, I geeked out and basically made a little program that records the magnetic field level, GPS co-ords and altitude every 5 seconds, and walked around the house and down the road to the shops for half an hour, then plotted the results as a 2D contoured colour map - quite interesting! Pointless... But kind of neat. It'd be interesting to have it on for a whole day whilst walking around London - although it absolutely rinses your battery having GPS on constantly.

So that's the colour map - redness designates a more intense magnetic field, the physical plot is longitude and latitude, altitude was ultimately excluded as it didn't really seem particularly reliable or useful.

Anyway, there's other cool things you can do with the magnetic field sensor, like if your phone doesn't have NFC and you want it to activate 'car mode' or something when you're in your car, just put a magnet behind the phone 'dock' in the car (something you could presumably easily make and stick to the dashboard so you can see the phone whilst driving), then setup an event trigger that activates car mode when Magnetic Field is over a certain level.

There's another thing I figured out too - using the proximity sensor you can make it have that air swipe feature to answer the phone that the S4 has. 

One final note for the geeks who are still interested: There's a clever way of ascertaining your approximate location without having regular GPS checks that costs valuable battery power. If you walk around for a bit, and have your phone scan for Cell Towers and signal strength in the vicinity, you can use them to then build a Profile where it triangulates your approximate position (to within 200m), at no extra battery cost. Of course, once you're within a certain zone according to this approximation, you can always tell your phone to then use GPS to really narrow it down.  

Finally, back to the second paragraph of this blog - when I referred to Tasker as an entry point into phone programming. After only a few days, and having realised the potential of the phone as the ultimate hacking tool, I downloaded the Android SDK and in all honesty, if you can do Tasker then you can blatantly do enough Python or Java to write an app with minimal learning. Get ready for the magnetic field reader & logger app coming soon... absolutely pointless and thoroughly interesting ;)

Cheers,
Duncan