[android-developers] Re: asynctask vs. FragmentRetainInstance.java in API demo

2013-02-01 Thread Streets Of Boston
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

Re: [android-developers] Re: asynctask vs. FragmentRetainInstance.java in API demo

2013-02-01 Thread Hand Green
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

Re: [android-developers] Re: asynctask vs. FragmentRetainInstance.java in API demo

2013-02-04 Thread Streets Of Boston
".. 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

Re: [android-developers] Re: asynctask vs. FragmentRetainInstance.java in API demo

2013-02-05 Thread Hand Green
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

Re: [android-developers] Re: asynctask vs. FragmentRetainInstance.java in API demo

2013-02-05 Thread 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 to implement your 'refresh' functionality. On Tuesday, Februar

Re: [android-developers] Re: asynctask vs. FragmentRetainInstance.java in API demo

2013-02-07 Thread Hand Green
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