Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: upload files totally in background

I have to create a multiple file uploads (3-7 photos), but this upload must be totally managed by the system, so that, even if the user closes the app, it should work until it completes uploading.

A little like Facebook, it upload a photo and if the app is killed: the progress also appears in the notification bar.

I currently use a class, I think FtpClient, which works well but if I close the app it stops. Everything is asynchronous but only for the app, not for the system.

How can I do that?

like image 284
D Ferra Avatar asked Mar 24 '15 09:03

D Ferra


1 Answers

You should use Service for this purpose. It will be running on background, and in it you can do all your upload/download work. You can look at this tutorial, and also read more about it from official documentation here and here.

You can just move all your logic from Activity/Fragment to Service, and it will be do it in background, even if your app is closed.

like image 74
VadymVL Avatar answered Sep 23 '22 17:09

VadymVL