in the below code send() function is executing many times in a second,i want to execute send() once in a second,how i change the code
timer.scheduleAtFixedRa
It happened for me when I used a TaskTimer
and the phone got into sleep mode. I think it is related to TimerTask
using Thread.sleep()
to provide the timing. This relies on uptimeMillis()
which according to documentation - 'is counted in milliseconds since the system was booted. This clock stops when the system enters deep sleep (CPU off, display dark, device waiting for external input), but is not affected by clock scaling, idle, or other power saving mechanisms. This is the basis for most interval timing such as Thread.sleep(millls)
'
Solution would be either to use AlarmManager
or WakeLocks
.