I am developing an application that is similar to the built-in AlarmClock application in Android 1.5. When an alarm is set, an icon is shown at the right corner of the notification bar.If the alarm is notified though NotificationManager, it is shown at the left corner of the status bar. I was curious about how the built-in AlarmClock puts an notification icon over there. So I looked at the master branch of AlarmClock's source code and got the following lines for doing this.
Intent alarmChanged = new Intent(Intent.ACTION_ALARM_CHANGED); alarmChanged.putExtra("alarmSet", enabled); context.sendBroadcast(alarmChanged);
Very simple. I copied and pasted to my project. But, it didn't pass the compilation and the error was from the missing definition of ACTION_ALARM_CHANGED in Intent class. Well. I flipped through pages of Intent's documentation and found nothing about ACTION_ALARM_CHANGED. But, if I replace this String constant with a string literal,
final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED"; Intent alarmChanged = new Intent(ACTION_ALARM_CHANGED); alarmChanged.putExtra("alarmSet", enabled); context.sendBroadcast(alarmChanged);
The notification was shown at the right location. This made me wonder if this ALARM_CHANGED string constant is buried somewhere in the source code? I decided to dig it out by myself. To start, I copied android.jar from SDK to a temporary location and extract it,
[josh@caterpillar: ~ > cp android.jar /tmp; cd /tmp [josh@caterpillar: /tmp > jar xf android.jar
Next, I tried to grep the name of this String constant in the extracted .class files to see if it is defined in some undocumented class.
[josh@caterpillar: /tmp > find . -name "*.class" >& class.txt [josh@caterpillar: /tmp > sed -i 's/.class//g' class.txt [josh@caterpillar: /tmp > foreach f (`cat class.txt`) foreach? echo "===> processing $f" foreach? javap -c -private $f | grep ALARM_CHANGED foreach? end
But, it didn't return anything to tell this String constant is defined at somewhere. My guess is that the content of this String constant is hard-coded in Android 1.5 SDK and it doesn't provide a public reference to it. Just a guess. The only way to verify my guess to look into the source code that I am syncing down.Mike Ditka - "If God had wanted man to play soccer, he wouldn't have given us arms."