【问题标题】:Uniquely Identify an Alarm Manager and re-shedule it唯一标识警报管理器并重新安排它
【发布时间】:2013-12-20 08:23:27
【问题描述】:

我正在开发一个具有多个警报管理器的 android 应用程序。它们是使用广播接收器触发的,还有一些只是在给定时间段后触发。

我想知道的是,我如何通过识别这多个警报来停止/取消警报管理器。

【问题讨论】:

    标签: android broadcastreceiver alarmmanager


    【解决方案1】:

    AlarmManager 由其待定意图唯一标识。浏览我的演示示例

    Intent imageFetchingService = new Intent(mContext, ImageFetchingService.class);
        PendingIntent imageFetchingPendingIntente = PendingIntent.getService(
                mContext, 0, imageFetchingService,
                PendingIntent.FLAG_UPDATE_CURRENT);
        AlarmManager alarmManager = (AlarmManager) mContext
                .getSystemService(Context.ALARM_SERVICE);
        alarmManager.cancel(imageFetchingPendingIntente); 
        alarmManager.set(AlarmManager.RTC_WAKEUP, 120000,
                        imageFetchingPendingIntente);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-02-02
      • 1970-01-01
      • 1970-01-01
      • 2011-01-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多