Android - running a method periodically using postDelayed() call

前端 未结 8 1384
一向
一向 2020-11-27 13:45

I have a situation in an Android app where I want to start a network activity (sending out some data) which should run every second. I achieve this as follows:

In th

8条回答
  •  渐次进展
    2020-11-27 14:20

    Why don't you create service and put logic in onCreate(). In this case even if you press back button service will keep on executing. and once you enter into application it will not call onCreate() again. Rather it will call onStart()

提交回复
热议问题