安卓:报警管理 [英] Android: Alarm Manager
本文介绍了安卓:报警管理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是在code:
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方法主要活动......如果我改变的东西设置,我想改变重复的时刻是什么?如何做到这一点?我应该杀了一个,开始新的?
This is my method where I start my alarm... I use it in my main activity in onCreate method... What if I change something in settings, and I want to change a time of Repeating? How to do that? I should kill that one and start new one?
推荐答案
如果您阅读文档你会发现以下内容:
If you read the docs you will notice the following:
如果已经有一个警报计划 对于相同IntentSender,它将 首先被取消。
If there is already an alarm scheduled for the same IntentSender, it will first be cancelled.
这篇关于安卓:报警管理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文