How to run a service every day at noon, and on every boot

后端 未结 3 568
孤街浪徒
孤街浪徒 2020-11-27 14:51

In my app I have SQLite database that has one table with date rows in milliseconds. I would like to have a notification shown every day IF 30 days has passe

3条回答
  •  眼角桃花
    2020-11-27 15:48

    In the demo it starts a service after 5 minutes since boot is complete which is just fine but what do I need to add to get it also start at every noon.

    Change the initial time of the setRepeating() call. The example shows one minute from now -- you would need to do the calculations to determine when the next noon is.

    You can see an example of that sort of calculation in this OnBootReceiver from a different sample project. Here, I am setting up the alarm to go off every day at a user-specified time.

提交回复
热议问题