Skip to content Skip to sidebar Skip to footer

Controlling The Alarm Icon In Status Bar

This question relates to Android versions pre-Lollipop. For Lollipop API, check related question: Lollipop API for controlling the Alarm icon in status bar I would like to know

Solution 1:

v5 Lollipop

Lollipop finally removed those private API features. This technique no longer works from v5.

I have posted a new question about Lollipop specifically, which has an answer on it:

Pre-Lollipop

This is how it is done, using private api properties:

protectedvoidsetStatusBarIcon(boolean enabled)
{
    IntentalarmChanged=newIntent("android.intent.action.ALARM_CHANGED");
    alarmChanged.putExtra("alarmSet", enabled);
    sendBroadcast(alarmChanged);
}

Thanks to Andy Savage on this Google Groups thread:


Important note: as stated above, this uses private, undocumented properties. All the usual warnings apply around this, as pointed out by Dianne Hackborn on the same thread:

Note that when you see a raw string like that ("android.intent.action.ALARM_CHANGED" and "alarmSet"), warning bells should be going off in your head that this is using private APIs.

And indeed this is.

If you use this, don't be surprised if it breaks in the future on randomly doesn't work on some devices.

Post a Comment for "Controlling The Alarm Icon In Status Bar"