Android Set Notification after 3 hours [duplicate]

2019-06-07 05:56发布

This question already has an answer here:

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条回答
劳资没心,怎么记你
2楼-- · 2019-06-07 06:21

follow it

AlarmManager am = (AlarmManager) sContext.getSystemService(Context.ALARM_SERVICE);
    am.set(AlarmManager.RTC, System.currentTimeMillis() + 3*60*60*1000, sAlertSender);
查看更多
登录 后发表回答