I am working on an app which is almost complete. In the app there is data files that are downloaded and uploaded from and to the sftp server .I want that when user downloads or upload files the process starts in the background letting user to use the app .I am also performing different condition check (which I dont intend user to wait for).I have used downloadManager but still I want to know how services could be useful to app.Please help .Thanks
Asked
Active
Viewed 174 times
0
-
duplicate of http://stackoverflow.com/questions/1969611/activity-with-progressbar-service-asynctask-for-downloading-but-how-to-u ? – NoBugs Jan 10 '13 at 05:31
-
Actually i dont want the user to wait for any downloads ..User may use app with predefined data and app notify him when download is complete – Navdroid Jan 10 '13 at 05:35
-
That's what a service is, background class as opposed to user-screen activity. AsyncTask is a thread, which calls its onPostExecute when finished. From there, start a notification. – NoBugs Jan 10 '13 at 05:40
1 Answers
0
1) create simple service class, define it in Manifest.
2) use Async Task to perform the download
As you are using services ;user dont have to interact with your app,as services run at background.
And Async Task let you know the status of download by onPreExecute() and onPostExecute().
After successful download show notification to user.

dd619
- 5,910
- 8
- 35
- 60
-
1I can't understand the relation between AsyncTask and Service.... What is the use of Service here, if someone uses AsyncTask too? – Pankaj Kumar Jan 10 '13 at 06:01
-
@pankaj: Async task run at background when your app is at foreground,And service run at background regardless the state of app.And using service and Async together is much better as together both run at background. – dd619 Jan 10 '13 at 06:35
-
I know about Service and AsyncTask. I am asking about how it is better to use both at same time. Can you explain? And one more thing you should read about DownloadManager. It will clear that how useful your answer is.... – Pankaj Kumar Jan 10 '13 at 06:45
-
It is good if you are using asynctask in service because service runs on **Main Thread** so that if you are using long process from service it can slow your UI.And Async runs in **separate thread** so it wont affect UI or other processing.and i dont think i need to read downloadManager. – dd619 Jan 10 '13 at 06:54
-