When application opens, splash screen is displayed and in the background I clean directory on external storage if it is exists, as soon as the directory is removed, another activity should be start. I was using AsyncTask, as ASyncTask is not handling configuration changes ,etc ,I want to use AsyncTaskLoader is it good idea, I mean if in the separate thread , I am trying to do cleaning action, and I am not fetching any data,what kind of threading mechanism I need to use?
Asked
Active
Viewed 185 times
0
-
What do you mean by `ASyncTask is not handling configuration changes` – Petro Mar 21 '16 at 20:39
-
well asyncTask is also on a separate thread, you know that right? – Shreyans Mar 21 '16 at 20:39
-
@Petro read this you will understand http://stackoverflow.com/questions/7120813/asynctaskloader-vs-asynctask – Shreyans Mar 21 '16 at 20:40
-
@Petro When the phone is rotated the activity is destroyed ,while ASyncTask is not, I need on my own destroy AsyncTask, etc. – I.S Mar 21 '16 at 21:00
1 Answers
0
Yes i think AsyncTask is a good choice here. You can check this question on SO for differences between AsyncTask , Handler and Thread for detailed pro/cons list. AsyncTask are appropriate for background processes that dont need to communicate with the UI thread and are tightly coupled with the activity (unlike an IntentService). Though for network operations nowdays volley is preffered over AsyncTask
-
If item onClick I delete sources from external storage ,and as a result the list should be notified as the item is removed ,in this case(when separate thread has interaction with UI Thread) AsyncTask is the right choice? – I.S Mar 21 '16 at 21:00
-
Well these kind of questions really depend on very specific details, but generally speaking and without any more info provided i would suggest you use handlers. read this to understand why i recommend handlers http://stackoverflow.com/questions/2523459/handler-vs-asynctask – Shreyans Mar 21 '16 at 21:06
-
The main problem for me, is to handle configuration change and with AsyncTask and HandlerThread it could be problematic. Even taking into account that fact is it worth to use it? What kind of details you need? – I.S Mar 21 '16 at 21:19