控制状态栏上的闹钟图标 [英] Controlling the Alarm icon in status bar

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

问题描述

这个问题涉及到Android版本pre-棒棒糖。对于棒棒糖API,检查相关的问题:

This question relates to Android versions pre-Lollipop. For Lollipop API, check related question:

  • <一个href="http://stackoverflow.com/questions/28367822/lollipop-api-for-controlling-the-alarm-icon-in-status-bar">Lollipop用于控制在状态栏
  • 闹钟图标API
  • 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:

据我了解有关系统,和我读过,在过去,它是由内置的系统的闹钟应用控制。而第三方应用程序有一个无根的设备上没有对其进行控制。没有理由,我们应该能够控制它。

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.

不过,及时v1.2.7控制该图标我的无根Galaxy Nexus的V4.2.1,和放​​大器; Nexus的5 v4.4.2。因此能够

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.

我不知道技术是怎么做到这一点的无根设备上。我怀疑一个黑客或无证code,但仍然有兴趣,如果任何人都可以提供一些线索。

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.

推荐答案

棒棒堂终于删除了这些私有API的功能。该技术不再V5工作。

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:

  • <一个href="http://stackoverflow.com/questions/28367822/lollipop-api-for-controlling-the-alarm-icon-in-status-bar">Lollipop用于控制在状态栏
  • 闹钟图标API
  • Lollipop API for controlling the Alarm icon in status bar

这是它是如何做的,用的私有API 属性:

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

重要提示:如上所述,这种使用私有,未记录的属性。所有常见的警告适用解决这个问题,正如刚才戴安娜Hackborn在同一个线程:

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:

请注意,当你看到一个原始字符串一样,   (android.intent.action.ALARM_CHANGED和alarmSet),警钟   在你的脑袋,这是使用私有的API应该去了。

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.

和这确实是。

如果你用这个,不,如果它打破在今后很惊讶   随机并没有某些设备上工作。

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天全站免登陆