I've an IntentService that should works indefinitely, even if application stops working.
This is my service:
public class TestService extends IntentService {
public TestService() {
super("test");
}
@Override
protected void onHandleIntent(Intent intent) {
while (true) {
// do works
SystemClock.sleep(60000);
}
}
}
And manifest:
<service android:name=".TestService" />
My service works well as long as I did not remove my application from the list of recent activities, but I want it works at all times.
Based on my searches I realized that if I set android:stopWithTask
to false
in the manifest and overriding onTaskRemoved
method in the service, I'll be able to handle my service.
<service
android:enabled="true"
android:name=".TestService"
android:exported="false"
android:stopWithTask="false" />
But this requires API level 14 or higher and my app API level is 8.
How can I solve my problem?