Wednesday, August 29, 2012

I was looking for some cron like command in android to make google nexus 1 vibrate in certain pattern (GOD in Morse Code :) for certain time. After a lot of googling, i found many resources to make this happen :) But it was not as straight forward as i thought...

Basically one needs to use android's AlarmManager to make it all work. Difference being that cron executes a command, while AlarmManager broadcasts an Intent and it will make your code do the magic when the alarm goes off :). BroadcastReceiver registered in your manifest takes this and runs when you reboot the system. One tricky thing is that you have to make sure that AlarmManager wake up the device in anticipation of alarm... God knows why! But this can be done via the WakeLock using PowerManager system service (make sure to add it in manifest!). Also one other critical thing is to force the system not to use SD via manifest.