gpt4 book ai didi

android - 警报广播类不再重复警报

转载 作者:行者123 更新时间:2023-11-30 03:57:09 25 4
gpt4 key购买 nike

请指导我,以便警报(邮件发送)重新编译并在事件发生前 1 天和事件发生前 30 分钟前向我提供邮件。

提前致谢。

public class MailAlarm extends BroadcastReceiver{

NotificationManager nm;

public void onReceive(Context context, Intent intent) {

nm = (NotificationManager) context
.getSystemService(Context.NOTIFICATION_SERVICE);

//int iUniqueId = (int) (System.currentTimeMillis() & 0xfffffff);

String event = Mail_Fill_Details.Discripton;
String name = Mail_Fill_Details.Person_Name;
String mail =Mail_Fill_Details.mailString;
try {
GMailSender sender = new GMailSender("taskschedulerfable@gmail.com", "xyz");
sender.sendMail("Reminder of "+event+" ("+name+")" ,
"REMINDER!! REMINDER!! REMINDER!! \n\n\nYou got a reminder about "+event+"("+name+") after 5 minutes\n\n\n",
"taskschedulerfable@gmail.com",
mail);
} catch (Exception e) {
Log.e("SendMail", e.getMessage(), e);
}

休息代码在这里...

Intent intent = new Intent(Mail_Fill_Details.this,
MailAlarm.class);
Bundle b12 = new Bundle();

b12.putString("serverresponse", Discripton);
b12.putString("serverresponse1", Person_Name);
b12.putString("serverresponce2", mailString);

intent.setAction("" + Math.random());
intent.putExtras(b12);
PendingIntent displayIntent = PendingIntent
.getBroadcast(Mail_Fill_Details.this,
iUniqueId, intent,
PendingIntent.FLAG_UPDATE_CURRENT);
alarmManager.set(AlarmManager.RTC_WAKEUP,
calendar.getTimeInMillis() - 300000,
displayIntent);
// alarmManager.setRepeating(AlarmManager.RTC_WAKEUP,
// calendar.getTimeInMillis(), 20, displayIntent);

最佳答案

我认为你应该使用 AlarmManagersetRepeating 方法而不是 set 方法。

am.setRepeating(type, triggerAtMillis, intervalMillis, operation);

关于android - 警报广播类不再重复警报,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13174222/

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