In my application i have a service created in a different thread than the main one (UI).
Then, in the service, i created 3 others threads that execute in background indefinitely.
But as soon as the phone goes in standby mode, these threads suspend their execution!
If i connect the phone to the pc via usb cable, instead, i see that the threads work properly, without suspending themeselves even when in standby mode.
But how to do not let threads have this behaviour in normal execution?
tnx
SOLVED:
I managed to get this simply by using the PowerManager object, which acquire a PARTIAL_WAKE_LOCK that leave the cpu active from the acquire() to the release().
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "My Tag");
wl.acquire();
..CPU will stay on during this section..
wl.release();
I managed to get this simply by using the PowerManager object, which acquire a PARTIAL_WAKE_LOCK that leave the cpu active from the acquire() invocation till the release() invocation.
In this way even if phone goes in stanbdy mode, thread is sure to be running.