问题
i am making an reminder application. If a user clicks the alert button, the alarm should be set for next 3 hours and a notification should be shown in the status bar after 3 hours completion.
I guess i have to use Alarm Manager to do this , but i dont know how to add 3 hours to current system time and set notification for that time.
回答1:
follow it
AlarmManager am = (AlarmManager) sContext.getSystemService(Context.ALARM_SERVICE);
am.set(AlarmManager.RTC, System.currentTimeMillis() + 3*60*60*1000, sAlertSender);
来源:https://stackoverflow.com/questions/12507665/android-set-notification-after-3-hours