I have a service that spawns a thread which runs a task every 3 seconds.
class MyService extends Service {
private Timer timer = new Timer();
public int onStartCommand(Intent intent, int flags, int startId) {
TimerTask task = new TimerTask() {
public void run() {
// something important
}
};
timer.scheduleAtFixedRate(task, 0, 3000);
return Service.START_STICKY;
}
...
}
My service runs fine when my phone is on, but when my phone is on standby, the service is often not responding.
Any clues as to how I can ensure my service is running while on standby?