Android Set Notification after 3 hours [duplicate]

折月煮酒 提交于 2019-12-08 04:55:43

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!