java - How to achieve precise timing execution of tasks?
怪我咯
怪我咯 2017-05-27 17:40:06
0
2
579

I want to use a service to implement a function that executes a piece of code (check out, submit to the server in GET mode, and do not open the activity if it can be opened) at a scheduled time (23:59) every day. I use TimerTask and Handler, but this is quite good. It's unreliable and basically doesn't work when the screen is turned off.

Later I heard about AlarmManger and JobScheduler. After reading the documentation, it seems that they are specially used to open Activity. What kind of logic should I use to complete the automatic checkout action?

怪我咯
怪我咯

走同样的路,发现不同的人生

reply all(2)
过去多啦不再A梦

AlarmManger does not say that it is specifically used to open Activity. It can open Broadcast, Service, and Activity. It depends on how you instantiate the Intent when you build the timer. As far as I know, the time AlarmManger initiates the alarm will have errors and inaccuracies for different mobile phones, especially Xiaomi machines. This may be a problem with the hardware clock. Don't know much about the others. for reference only.

巴扎黑

Android control is becoming more and more strict, but you should still use it JobScheduler吧, JobSchedulerThe original intention of the design is to make reasonable use of mobile phone resources.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!