I want to send notification every day at the same time, saying "Good morning". I know create notifications for a specific day/hour, but for this case I do not know.
Asked
Active
Viewed 513 times
-4
-
Do you want to send it from your server? or just to create a notification every day at 8am for example – fbwnd Jun 29 '17 at 09:35
-
Yes, you could write an app for that. – arminb Jun 29 '17 at 09:36
-
`... Ideas?` Yes: **Google**. – Phantômaxx Jun 29 '17 at 09:36
-
@fbwnd I create every day because I want the application user to receive this notification in the morning – Wouva Jun 29 '17 at 09:41
1 Answers
0
This answer solves the question using AlarmManager
.
Intent myIntent = new Intent(Current.this , NotifyService.class);
AlarmManager alarmManager = (AlarmManager)getSystemService(ALARM_SERVICE);
pendingIntent = PendingIntent.getService(ThisApp.this, 0, myIntent, 0);
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY, 12);
calendar.set(Calendar.MINUTE, 00);
calendar.set(Calendar.SECOND, 00);
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), AlarmManager.INTERVAL_DAY , pendingIntent); //set repeating every 24 hours

Abhi
- 3,431
- 1
- 17
- 35
-
As @Abhi mentioned. use that code. In addition, pay attention to register to boot_completed as the alarm will not work after reboot – fbwnd Jun 29 '17 at 09:43