I have started a AsyncTask
to decode the contents in a file on a Button
click. AsyncTask
is running fine, now I pressed home button. Activity
entered into onStop()
state. Now what happens to my AsyncTask
, Will it run or stop in this onStop()
state?
Asked
Active
Viewed 781 times
1

Kanwaljit Singh
- 4,339
- 2
- 18
- 21

saa
- 1,538
- 2
- 17
- 35
-
see http://stackoverflow.com/questions/2531336/asynctask-wont-stop-even-when-the-activity-has-destroyed – Shayan Pourvatan Mar 06 '14 at 09:33
-
1It will continue to run – mach Mar 06 '14 at 09:33
2 Answers
1
activity stop will not make your async task to stop. Your async task will continue and if you have some reference of view in post execute it will cause exception.
You can also use AsyncTaskLoader
instead.
Read about it:

vipul mittal
- 17,343
- 3
- 41
- 44
1
No it can't be. Your activity has been stopped your AsyncTask will continues. IF you want to stop it you have to cancel your AsyncTask.

Piyush
- 18,895
- 5
- 32
- 63