gpt4 book ai didi

android - 在 Android 中设置更多警报?

转载 作者:行者123 更新时间:2023-11-30 04:46:29 25 4
gpt4 key购买 nike

我使用以下代码创建警报。

String strDateTime=strDate+" "+strTime;             
DateFormat dfm = new SimpleDateFormat("yyyy-MM-dd HH:mm");
Date alarmTime = null;
try {
alarmTime = dfm.parse(strDateTime);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

long setAlarmTime=alarmTime.getTime();

Intent myIntent = new Intent(context, MyAlarmService.class);
pendingIntent = PendingIntent.getService(context, 0, myIntent, 0);

AlarmManager alarmManager = (AlarmManager)getSystemService(ALARM_SERVICE);

//set time and get the Intent
alarmManager.set(AlarmManager.RTC_WAKEUP, setAlarmTime, pendingIntent);

如果我设置了多个闹钟,最后一个将被执行。我如何在android中添加更多的闹钟时间?

最佳答案

尝试在每个 AlarmManager.set 上为您的每个 Intent(代码中的 myIntent)提供一些随机数据(通过 setDat 调用)打电话

AlaramManager 重置之前为相同的 PendingIntent 设置的警报(而您的 PendingIntents 始终相同)

关于android - 在 Android 中设置更多警报?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4848106/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com