I used RoboSpice library to do asynchronous tasks. From their examples, the spice service is declared in BaseActivity, it starts in activity's onStart method, and stops in activity's onStop. Everything is fine, but when I want download file from internet, and then I change to another activity, this download task is cancelled, because the spice service is stopped. It looks like:
public abstract class BaseActivity{
/** The request manager. */
private SpiceManager requestManager = new SpiceManager(RequestService.class);
@Override
protected void onStart() {
requestManager.start(this);
super.onStart();
}
@Override
protected void onStop() {
requestManager.shouldStop();
super.onStop();
}
}
So I wonder is there any safe way to keep the download task continue running from Spice service (this task doesn't touch UI), and another tasks work normally (mean they can be cancelled when stop activity) but it still can respect the activity life circle.