The data hoarder in me is making an appearance. Been tracking my GPS coordinates more consistently for the past few weeks, but InstaMapper on Android is less than ideal for the task. Geoloqi as well. They consume too much battery. I’d rather not have to turn them off when I’m going to stay put for a while – I don’t enjoy fiddling with my phone in public.

Last weekend I began a project of my own that uses the accelerometer to determine when GPS should turn on. Every N seconds it checks the accelerometer for motion, and pulls GPS coordinates into an SQLite database if I’m moving. It doesn’t ping the accelerometer or GPS consistently, and it doesn’t transfer the coordinates to a remote server (though a conservative approach to this will come later).

The project sounds simple enough, but I’m new to Android apps so it’s actually been quite a frustrating ordeal. I’ve had to understand and piece together Handler, HandlerThread, Looper, Service, LocationListener, SensorEventListener, AlarmManager and WakeLock objects. I’ve finally got the sensor reading, wakeup alarm and wake lock acquisition stuff working, but I’m still trying to wrap my head around how to keep the main service thread alive while the asynchronous sensor operations run in another thread. I don’t want to block the UI thread while I wait for the callbacks from those devices. It’s probably something simple, but I haven’t hit it yet. Going on two weeks and I just want to get prototype #1 working.