Android regular task (cronjob equivalent)

前端 未结 5 647
时光取名叫无心
时光取名叫无心 2020-12-05 19:10

The last time this question was asked (by a different user), the answer response was:

If this is in a running activity, you could use Timer/TimerTask

5条回答
  •  天涯浪人
    2020-12-05 19:55

    If you want to build a cronjob runner then what you want is a Service:

    A Service is an application component that can perform long-running operations in the background and does not provide a user interface. Another application component can start a service and it will continue to run in the background even if the user switches to another application. Additionally, a component can bind to a service to interact with it and even perform interprocess communication (IPC). For example, a service might handle network transactions, play music, perform file I/O, or interact with a content provider, all from the background.

提交回复
热议问题