I am making a reminder app where the user sets an interval for notification reminders. The user sets the hourly interval and then the daily interval.
For example the user wants to get notified every 3 hours on Mondays, Tuesdays and Saturdays.
I'm using this method to send notifications hourly:
private void scheduleNotification(String notificationTitle, int notificationID, int hours, int minutes) {
Intent intent = new Intent(mContext, NotificationPanelReceiver.class);
intent.putExtra("title", notificationTitle);
intent.putExtra("notificationID", notificationID);
PendingIntent pendingIntent = PendingIntent.getBroadcast(
mContext
, notificationID
, intent
, PendingIntent.FLAG_IMMUTABLE);
AlarmManager manager = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE);
long repeatInterval = (minutes * 60 * 1000) + (hours * 60 * 60 * 1000);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
manager.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP
, SystemClock.elapsedRealtime() + repeatInterval
, repeatInterval
, pendingIntent);
}
}
So I need this interval to repeat weekly on user selected days
Does anyone know how I can make that work?