After your Fragment, the one without a UI, has started the AsyncTask, i.e.
after the AsyncTask's 'execute' method has been called, it can stop it by
calling 'cancel' on it.
task.execute(...);
...
...
And on some event, (Fragment's onDestroy for example), you just call.
task.cancel(t
Thank you for your response. If I use a fragment as a worker thread, I will
adapt the pattern in FragmentRetainInstance.java. Because it is unnecessary
for a worker fragment to start a asynctask, the worker thread can do the
task directly by using java.lang.Thread.
However, I still do not understa
".. it is unnecessary for a worker fragment to start a asynctask ..."
I don't understand the statement above. A Fragment without a UI is not a
worker thread. It is just a Fragment without a UI.
You can use it to tie data/tasks in the Fragment to the lifecycle of an
activity that is hosting the
As for ".. it is unnecessary for a worker fragment to start a asynctask
...", let me put it in another way.
Yes, I agree a fragment without UI is not a worker thread. Why I said "..
it is unnecessary for a worker fragment to start a asynctask ..." was about
the FragmentRetainInstance.java. It does
Instead of Threads or AsyncTasks that do the background work getting the
data from the server, use Loader (AsyncLoader).
You can use the LoaderManager to initially load them and also to restart
them. Restarting them would allow you to implement your 'refresh'
functionality.
On Tuesday, Februar
Thank you. It is very useful.
2013/2/6 Streets Of Boston
> Instead of Threads or AsyncTasks that do the background work getting the
> data from the server, use Loader (AsyncLoader).
> You can use the LoaderManager to initially load them and also to restart
> them. Restarting them would allow you
6 matches
Mail list logo