嗨,我是android开发的新手,我正在开发一个与警报相关的应用程序,notification
而我在特定时间设置警报时一切正常,警报通知正确,但警报notification
有时会重复,而我不重复它我怎样才能避免这个问题.
这是我的代码:
Intent intent = new Intent(this, AlarmReceiver.class);
intent.putExtra("ti", name);
intent.putExtra("id", id);
PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
AlarmManager alarmManager = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
final Calendar cal = Calendar.getInstance();
switch(Cun.valueOf(repeat)) {
case No:
alarmManager.set(AlarmManager.RTC_WAKEUP, targetCal.getTimeInMillis(), pendingIntent);
break;
}