2
我使用AlarmManager類在特定時間內用戶的日常通知報警時間(用戶會選擇從時間選取的時間) 每一件事偉大的工作al7mdllah ^^ 但我想從alarmManger獲得這個時間並將其顯示在應用程序中以獲得更好的UX 有什麼方法可以獲得鬧鐘時間嗎?獲取其以前添加到AlarmManager
這裏是我的代碼
public void witer_reminder(View view)
{
am = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
Intent intent = new Intent(this, Witer_Notification.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0,
intent, PendingIntent.FLAG_CANCEL_CURRENT);
Calendar cal = Calendar.getInstance();
Calendar calSet = (Calendar) cal.clone();
calSet.set(Calendar.HOUR_OF_DAY, picker.getCurrentHour());
calSet.set(Calendar.MINUTE,picker.getCurrentMinute());
calSet.set(Calendar.SECOND, 0);
calSet.set(Calendar.MILLISECOND, 0);
if(calSet.compareTo(cal) <= 0){
//Today Set time passed, count to tomorrow
calSet.add(Calendar.DATE, 1);
}
am.setRepeating(AlarmManager.RTC_WAKEUP, calSet.getTimeInMillis(),
24*60*60*1000, pendingIntent);
}
明白了,謝謝 – Pixbyte