Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Repeating notification set quiet hours

I have looked around and can't find any answers regarding this specific problem.

I have an app which i have repeating notifications (set by the user by hours eg. every 2 hours)

The user also needs to set quiet hours so the notifications don't go off during the night. How would i implement this? I am using broadcast receiver, can i pass intent to the broadcast and include an if condition (between times picked) or is there a way to do this before sending the intent?

my code which sets the time is below but I'm struggling to figure out a way to add the quiet hours in...

alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), rcRepeatTime, broadcast);
like image 598
Nathan W Avatar asked Jul 08 '26 05:07

Nathan W


1 Answers

Figured it out by getting times off time pickers set by user, then passing the intent to the broadcast receiver class. Receiver class gets that intent then pseudocode= if(times within A && B){send notification}else{no notifications};

This way i can have hourly notifications if chosen but not wake the user in the night etc. Probably was an easy thing for most people but I'm still 'learning Android' so I'm happy with that :)

like image 148
Nathan W Avatar answered Jul 10 '26 16:07

Nathan W



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!