Android saves state and progress of AsyncTask

In an application, I am developing atm. I am using asynctasks to upload a video to a website as it stands now if the app process is killed (User returns to home screen with a reverse key) these asynctasks are lost. ideally I would like the downloads to continue despite the application process being killed, but I don't think that is possible.

I wonder if there is a way to somehow save my progress (maybe website API support is needed?), Or if not save the asynthesis data and restart it when the app is opened again.

The Vimeos app seemed to be able to resume uploading videos even after you killed the application process, which is exactly what I hope.

Appreciate any ideas and suggestions.


source to share

1 answer

I think you may be using the wrong architecture.

Everything that is necessary to survive between activity transitions is more suitable for the Service. The service runs in the background (possibly even after the application is closed) and allows for lengthy actions such as performing a download.

To kill the application process, but the service continues to run, you can assign the service to a separate android process using android: process in the manifest.

See also this topic: How do I keep a service running in the background even after exiting an application?



All Articles