I want to generate notifications for every 24 hours for which I've implemented the code, but on runtime, the notification is appearing multiple times on a single day. I.E. When the notification appeared in the panel and I swiped it off the panel. The same notification should appear on the next day and not multiple times on the same day.
Here's the code:
Calendar cal = Calendar.getInstance();
Date d = cal.getTime();
DateFormat df = new SimpleDateFormat("dd");
String date_str = df.format(d.getTime());
int hour = cal.get(Calendar.HOUR_OF_DAY);
int minute= cal.get(Calendar.MINUTE);
cal.set(Calendar.HOUR_OF_DAY, hour);
cal.set(Calendar.MINUTE, minute);
cal.set(Calendar.SECOND, 0);
intent.putExtra(REQUEST_CODE_STRING, requestCode);
// cancelTrigger(context,requestCode,intent);
// cancelTriggerAlarm(context);
PendingIntent sender = PendingIntent.getBroadcast(context, requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
//
am.setInexactRepeating(AlarmManager.RTC_WAKEUP,
cal.getTimeInMillis(),
1000 * 60 * 60 * 24, // 24 hrs in milliseconds
sender);