Suggestion About Asynctask
Solution 1:
What you have should be working just fine. You are correctly executing and parsing the results of the request off the UI thread. However, there are a couple minor things you can do to make it clearer.
stringArray looks like a field on the AsyncTask. This is not necessary the way you have the AsyncTask defined since you are already passing the stringArray directly into the onPostExecute() method. You should instead declare stringArray directly in the doInBackground() method.
Other thing I noticed is it looks like you might be keeping a reference to your Activity in the AsyncTask based on what you are doing in onPostExecute(). You are calling this.obj.setFeedsData(result);. If your AsyncTask is an inner class of the Activity using it you can call setFeedsData(result); directly instead.
If your AsyncTask is not an inner class it is usually best to pass the results back to the object interested in them through an interface in case you need to reuse the AsyncTask elsewhere.
Post a Comment for "Suggestion About Asynctask"