Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 how to turn on / off the system Alarm icon in the status bar as shown in this image:

Android system Alarm icon

From what I understand about the system, and what I've read in the past, it is controlled by the built in system alarm clock app. And 3rd party apps have no control over it on an unrooted device. There is no reason we should be able to control it.

  • Android, the alarm icon on the right side of notification area?

However, Timely v1.2.7 controls this icon on my unrooted Galaxy Nexus v4.2.1, & Nexus 5 v4.4.2. So it is possible.

I wonder what the technique is to do this on an unrooted device. I suspect a hack or undocumented code but still interested if anyone can shed some light.

like image 601
Richard Le Mesurier Avatar asked Apr 16 '14 09:04

Richard Le Mesurier


People also ask

Why is there an alarm icon on my status bar?

An alarm icon will be displayed on the status bar if you have set up an alarm or reminder in a third-party app. Go to the app's settings screen and check whether alarms, reminders, or similar features have been enabled. If so, disable them and try again.

How do I get rid of the alarm icon on my iPhone status bar?

All replies. Yes you can. Open the Clock app, and switch off the alarms that are activated. If you have Bedtime enabled, then turn that feature off.


Video Answer


1 Answers

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:

  • Lollipop API for controlling the Alarm icon in status bar

Pre-Lollipop

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

protected void setStatusBarIcon(boolean enabled)
{
    Intent alarmChanged = new Intent("android.intent.action.ALARM_CHANGED");
    alarmChanged.putExtra("alarmSet", enabled);
    sendBroadcast(alarmChanged);
}

Thanks to Andy Savage on this Google Groups thread:

  • AlarmManager with alarm icon
  • direct link to archived post

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.

like image 153
Richard Le Mesurier Avatar answered Sep 23 '22 23:09

Richard Le Mesurier