Start app at a specific time

前端 未结 3 1213
不知归路
不知归路 2020-11-29 01:30

I was wondering if it\'s possible (and if it is how) to start up my app at a specific time, something like an alarmclock which goes off at a specific time. Let\'s say I wan

3条回答
  •  囚心锁ツ
    2020-11-29 02:20

    You are probably looking for AlarmManager, which let's you start services / activities / send broadcasts at specific intervals or a given time, repeating or not. This is how you write memory friendly background services in android. AlarmManager is sort of like cron in unix. It allows your background service to start, do its work, and get out of memory.

    You probably do not want to start an activity (if that's what you meant by "application"). If you want to alert the user that something has happened, add an alarm that starts a receiver at a given time, and have the receiver add a notification. The notification can open the application when clicked. That's less invasive than bringing some potentially unwanted activity to the foreground.

提交回复
热议问题