how to keep an Intent service running

后端 未结 3 1303
忘了有多久
忘了有多久 2020-12-30 10:58

I have two examples of Intentservice. One is the Download example in the commonsware book. the other is at http://www.vogella.com/articles/AndroidServices/article.html#ser

3条回答
  •  Happy的楠姐
    2020-12-30 11:37

    You can achieve this in either of two ways,

    • AlarmManager
    • TimerTask

    AlarmManager is android's in-buite class that allows you to execute certain action on particular time peroid.

    TimerTask does same thing as AlarmManager, you can repeat certain action of your code again and again.

    However AlarmManager is ligher in the execution so i suggest you to go with AlarmManager class.

    Create an AlarmManager that fetches the GPS Co-ordinates and post them to server on regular interval basis.

    Have a look at to this AlarmManager Example.

提交回复
热议问题