【问题标题】:Android: Alarm ManagerAndroid:警报管理器
【发布时间】:2015-04-03 21:06:57
【问题描述】:

这是代码:

public void startAlarm(Context context) {
    Intent intent = new Intent(context, SyncService.class);
    PendingIntent sender = PendingIntent.getService(context, 0, intent, 0);

    AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
        am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,
                10 min, 20 min, sender);

}

这是我开始闹钟的方法...我在 onCreate 方法的主要活动中使用它...如果我更改设置中的某些内容,并且我想更改重复时间怎么办?怎么做?我应该杀死那个并开始新的吗?

【问题讨论】:

    标签: android


    【解决方案1】:

    如果您read the docs,您会注意到以下内容:

    如果已经安排了闹钟 对于同一个 IntentSender,它将 首先被取消。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-07-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-25
      相关资源
      最近更新 更多