检测默认的闹钟应用程序警报 [英] detect default alarm clock application alarms

查看:150
本文介绍了检测默认的闹钟应用程序警报的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有一种方法(可能是一个系统广播),要知道,闹钟默认的应用程序现在就开始响了。

I would like to know if there is a way (probably a system broadcast) to know that the alarm clock default application is now start ringing.

如果不是 - 我就心满意足了还,如果我能得到的所有报警的progrematically名单已经由用户设置(我可以提取每一个报警的准确时间它会响。)

if not - I'll be satisfied also if I could get progrematically list of all active alarms been set by the user(which I could extract from each alarm the exact time it would ring..)

我试过到目前为止:

我知道有一种方式来获得格式化字符串到一个报警:

I know there is a way to get formatted string to next alarm:

  String nextAlarm = Settings.System.getString(context.getContentResolver(), Settings.System.NEXT_ALARM_FORMATTED);

该方法返回的某些设备(如所有的三星Galaxy系列..)一个空字符串,即使报警设置(三星原生的闹钟应用程序。)。我敢打赌,它仅适用于与默认警报应用程序结点设备。

this method returns for certain devices (such all Samsung Galaxy Series..) an empty string, even if the alarm was set (by Samsung native alarm clock app..) . I bet it works only on nexus devices with the default alarms app.

我想获得一个,将工作无论哪种方式,通用的解决方案。

I would like to get a generic solution that would work either way.

TIA

更新

我会努力让我的问题更清楚:

I will try to make my question clearer:

我不感兴趣(直接)知道所有PendingIntent举行的AlarmManager

I'm not interested (directly) to know all PendingIntent been held by the AlarmManager

我感兴趣的只是了解用户设定隐含报警,特别是对那些他激活唤醒。

I'm interested only to know about alarms set implicitly by the user, especially about the ones he activated for waking up.

我的最终目标是获得暗示用户醒来。仅此而已。

推荐答案

我的的疑问,你会发现一个解决方案。

I highly doubt that you'll find a solution for this.

报警由 AlarmManagerService 维护。由于它不包含在SDK中,反射可能得到的东西出来的唯一途径。但是,从外观上来看,即使反射不能帮助你在这里:

Alarms are maintained by AlarmManagerService. Since it is not included in the SDK, reflection might be the only way to get something out of it. But from the looks of it, even reflection cannot help you here:

  • 需要访问AlarmManagerService $批次#报警和LT; --- ArrayList的<报警>
  • 需要访问AlarmManagerService#mAlarmBatches< --- ArrayList的<批次>
  • 使用反射:
    • 类< ? > AMS =的Class.forName(com.android.server.AlarmManagerService)
    • 字段mAlarmBatches = ams.getDeclaredField(mAlarmBatches)
    • 在对象listOfBatches = mAlarmBatches.get(????)
    • 卡住
    • Need access to AlarmManagerService $ Batch # alarms <--- ArrayList< Alarm >
    • Need access to AlarmManagerService # mAlarmBatches <--- ArrayList< Batch >
    • Use reflection:
      • Class< ? > ams = Class.forName("com.android.server.AlarmManagerService")
      • Field mAlarmBatches = ams.getDeclaredField("mAlarmBatches")
      • Object listOfBatches = mAlarmBatches.get(????)
      • Stuck

      似乎是死路一条给我。无法实例 AlarmManagerService - 甚至不是通过访问和调用构造函数(因为它调用本地方法)

      Seems like a dead end to me. You cannot instantiate AlarmManagerService - not even by accessing and invoking its constructor (because it calls a native method).

      推理的另一行:下面就一起来看看 AlarmManagerService $报警类:

      Another line of reasoning: Here's a look at AlarmManagerService$Alarm class:

      public static class Alarm {
          public int type;
          public int count;
          public long when;
          public long windowLength;
          public long whenElapsed;    // 'when' in the elapsed time base
          public long maxWhen;        // also in the elapsed time base
          public long repeatInterval;
          public PendingIntent operation;  <<<<<<============Problem==============
          public WorkSource workSource;
      
          ....
          ....
      }
      

      如果可以访问到 PendingIntent ,什么而取消报警随意阻止他们 - 已设置由其他应用程序报警?

      If one can gain access to the PendingIntent, what's stopping them from cancelling alarms at will - alarms that have been set by other apps?

      不过,我希望这里有人能帮助你。

      Still, I hope someone here can help you out.

      链接:<一href="http://androidxref.com/4.4.2_r1/xref/frameworks/base/services/java/com/android/server/AlarmManagerService.java"相对=nofollow> AlarmManagerService

      这篇关于检测默认的闹钟应用程序警报的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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