Lollipop API for controlling the Alarm icon in status bar
Asked Answered
H

1

10

This is a Lollipop-specific question, since the API has changed. To find out how to do this on earlier versions, see related question:


I would like to know how to turn on / off the system Alarm icon in the status bar as shown in this image:

enter image description here

Timely Alarm Clock controls this icon on Lollipop as of release 1.3. Prior to that release, the code was using private APIs as detailed in the related question.

The new technique they use works on an unrooted Nexus 5 running v5.0.1.


Update

It looks like there is a lot more the this new API than just changing the icon. The lock screen now also displays the time I have set the alarm for.

Hagride answered 6/2, 2015 at 14:21 Comment(2)
@Willis thx for the bounty. Was about to put one up myself, if only to award to nandeesh for his answer.Hagride
No problem. I was curious as well. Always happy to help out a fellow Afrikaaner.Muniments
C
12

AlarmManager has a new api to set this.

AlarmManager.setAlarmClock (AlarmManager.AlarmClockInfo info, PendingIntent operation)

If you do this, the alarm shows on notification bar and LockScreen .

Consortium answered 9/2, 2015 at 3:43 Comment(2)
this by default shows and hides icon when alarm is set/removed. But did you find a way to actually control this icon? I used to have option to not show the icon when alarm is set and now users complain that icon takes space in status bar needlessly. So, any way to hide it even when alarm is set?Reconstruction
I think that from api 23 we should use AlarmManager .setExactAndAllowWhileIdle(), but this is not showing the icon. setAlarmClock will show the icon, but what's the solution? Should we use these two methods together?Legit

© 2022 - 2024 — McMap. All rights reserved.