0

I am a beginner i want to Give Notification on specific day in long time example i want to set Notification for 6 months longer Should I use َAlarm Manager or countdown timer , Or I can do it by Conditions and joda-time Component?

  • If you want you can use firebase to schedule the notification but that requires the device to have an internet condition. Otherwise using alarm manager would be sufficient. See https://stackoverflow.com/questions/36902667/how-to-schedule-notification-in-android – Isaac Jun 17 '18 at 09:28
  • I do not want to use firebase, Because I do not always have access to the Internet, also Alarm Manager is not good for a long time , Is the countdown timer not good for this? – اندرولند androland Jun 17 '18 at 09:37
  • A countdown timer will have to be run in a service that could be stopped by doze. Also unless you save the state of the countdown timer you might loose track of the countdown when the device is switched off – Isaac Jun 17 '18 at 09:42
  • ok so Can I use the condition? For example, if the date is equal to today, the notification will be displayed,Dates are recorded in the database I can record the date for the next 6 months – اندرولند androland Jun 17 '18 at 09:46
  • You can already set Alarm Manager to do that. You just have to ensure that the alarm is set again whenever the device is switched on again https://stackoverflow.com/questions/17673746/start-alarmmanager-if-device-is-rebooted – Isaac Jun 17 '18 at 09:48
  • I'm a beginner and it's hard for me,But, if possible, I'll be more comfortable with the bets – اندرولند androland Jun 17 '18 at 09:52

1 Answers1

2

timer is not a good idea because it may kill by os but you can use the alarmManager or workManager but you should also listing on device boot complete and register your task again to alarmManager

here is a good tutorial for using alarm manager :

https://en.proft.me/2017/05/7/scheduling-operations-alarmmanager-android/

Amir Hossein Mirzaei
  • 1,592
  • 1
  • 6
  • 15