2017-06-29 72 views
-4

我想每天同時發送通知,說「早上好」。 我知道創建特定的一天/小時的通知,但對於這種情況我不知道。Android通知「每天早上好」

+0

是否要從服務器發送它?或者只是每天早上8點創建通知,例如 – fbwnd

+0

是的,您可以爲此編寫一個應用程序。 – arminb

+0

'......想法?'是:** Google **。 –

回答

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 
+0

正如@Abhi所述。使用該代碼。另外,請注意註冊boot_completed,因爲重啓後鬧鐘不會工作 – fbwnd

+0

@Wouva答案沒有解決問題嗎? – Abhi