Android通知"每天早上好"

时间:2017-06-29 09:34:28

标签: android notifications

我想每天同时发送通知,说"早上好"。 我知道创建特定日期/小时的通知,但对于这种情况我不知道。

1 个答案:

答案 0 :(得分:0)

answer使用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