控制状态栏中的警报图标 [英] Controlling the Alarm icon in status bar

查看:26
本文介绍了控制状态栏中的警报图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此问题与 Lollipop 之前的 Android 版本有关.对于 Lollipop API,请检查相关问题:

但是,Timely v1.2.7 控制此图标在我无根的 Galaxy Nexus v4.2.1 上,&Nexus 5 v4.4.2.所以这是可能的.

我想知道在无根设备上执行此操作的技术是什么.我怀疑有黑客攻击或未记录的代码,但仍然有兴趣了解是否有人可以提供一些线索.

解决方案

v5 Lollipop

Lollipop 最终删除了那些私有 API 功能.此技术在 v5 中不再适用.

我专门发布了一个关于棒棒糖的新问题,上面有答案:

前棒棒糖

这是如何完成的,使用私有 api 属性:

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

感谢 Andy Savage 在此 Google 网上论坛帖子中:

<小时>

重要说明:如上所述,这使用私有的、未记录的属性.正如黛安·哈克伯恩 (Dianne Hackborn) 在同一线程中指出的那样,所有常见警告都适用于此:

<块引用>

请注意,当您看到这样的原始字符串时(android.intent.action.ALARM_CHANGED"和alarmSet"),警铃您应该会想到这是使用私有 API.

确实如此.

如果你使用这个,如果它在未来坏了,不要感到惊讶随机在某些设备上不起作用.

This question relates to Android versions pre-Lollipop. For Lollipop API, check 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:

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.

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.

解决方案

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:

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:


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.

这篇关于控制状态栏中的警报图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆