I just added the ability to set alarms in one of my apps. There are lots of tutorials on the web on how to implement this. I found http://justcallmebrian.com/?p=129 to be a very clean explanation.

So I set the alarm from my app using AlarmManager, I implemented both a BroadcastReceiver to handle BOOT_COMPLETED to reschedule any pending alarms if the device was rebooted. I wrote my BroadcastReceiver to handle the actual alarm. Everything was working great until I started tinkering around.

In the Android Dev Guide section about notifying the user (http://developer.android.com/guide/topics/ui/notifiers/notifications.html), down near the bottom are some sections for optionally adding sounds, lights, etc to the notification.

I wanted LIGHTS, SOUNDS, the works, and I figure let the user decide those, so I just chose to use the DEFAULTS. I originally had DEFAULT_SOUND and DEFAULT_LIGHTS, then I changed that to DEFAULT_ALL and that is where things went to hell in a handbasket.

I started having issues where everything was working as before, but I was getting a Force Close after the alarm was received and posted to the notification bar. All seemed normal – the default sound was playing, my icon showed up, my ticker message showed up, my pending intent showed in the notification pull down.

Digging through the LogCat, I saw no pertinent info. I surrounded my onReceive() method contents with a try/catch block which didn’t help much. Mostly the LogCat complained of an uncaught exception with little pointing to the actual reason.

Problem solved – I am posting this here in hopes of helping someone else with the same issue – DEFAULT_ALL includes DEFAULT_VIBRATE – if you do not have the VIBRATE permission specified in your AndroidManifest.xml file, you will have the same troubles.

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Twitter