Friday, 15 February 2013

Android: mhandler.postDelayed() not accurate when screen off -


I am using mhandler.postDelayed (runable, 5000) to write data in a file for every 5 seconds .

When the screen is switched off, I have seen the file for the post daylight (runner, 5000). This is accurate for some time, but for one hour, PostDelayD (Runner, 5000) time to grow for 10 seconds.

After two hours, Post Delayed (Runner, 5000) increases by 15 seconds. After three hours, there should be an increase of 20 csec for Post Delayed (Runner, 5000).

It seems very strange that Delayed trigger time changes over time.

Am I expecting this or is there any error in my code?

You should try to use something more than handler.

Try:

  int delay = 1000; // Milliseconds ActionListener Performance = New Executionist () {Public Actions executed (ActionEvent evt) {// ... Fix work ...}}; New Timer (Delay, Task Executioner). Start ();    

No comments:

Post a Comment