Elezabeth Mathew
Elezabeth Mathew

Reputation: 161

Continue uploading even when the app gets killed(Android)

I want an upload operation to get completed even when the application is running in background. The process should get completed even if the application gets killed while opening other application. Could anyone pls suggest me some solutions?

Upvotes: 0

Views: 365

Answers (2)

dinesh707
dinesh707

Reputation: 12592

Your application do not get killed by opening other applications. Check the Android life cycle. And the best way to upload a file is to do it on a thread. Whether you close the app or not started thread will keep working on.

Upvotes: 1

Raghav Sood
Raghav Sood

Reputation: 82563

Use a service, and attach an ongoing notification to it. This will prevent Android from killing your app by and large, but it is still possible you may be killed in the most extreme scenarios. However, this is the best you can do, unless your app is in the foreground throughout the upload.

Upvotes: 2

Related Questions