T
T
TimkaTV2015-06-02 11:59:56
Android
TimkaTV, 2015-06-02 11:59:56

What are the reasons for the delay in Android Service?

Good afternoon,
Such a problem:
There is a service that sends notifications (notification) on a schedule, during operation, if the device is inactive, there are delays in the service. That is, notifications are late, and the delay depends on the time of inactivity.
Inside the service, there is an infinite loop in the child thread that checks the condition:
if(date.before(new Date())) { ... }(as well as whether a notification has already been sent)
The problem is that if the device is inactive for several hours, then notifications do not come at all.
Thank you!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
KaktusTeam, 2015-06-02
@TimkaTV

Good afternoon,
Just a cycle in the service is not enough, the device needs to be woken up after it has fallen asleep. I think this is done so that the services do not plant the battery while the device is turned off.

C
Copperfield, 2015-06-02
@Copperfield

You need to pull WakeLock .
If the service is started from a BroadcastReceiver, use WakefulBroadcastReceiver

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question