I'm wondering where I should place my AsyncTask
in my android project. As of right now I'm implementing an AsyncTask
as a private class of my activity its running under. What I am going to do is in each activity that has a network call I will implement its own private class of AsyncTask
. I have a few questions though
In The
preexecute
method it says I can interact with the activity and place a spinner or progress bar. I do this by usingMy_Activity_Class_Name.this
. So my question is does that line of code reference the activity theAsyncTask
is called from? If so I believe that will be a static method. How do i actually pass in the instance of the class so I can interact with non static functions?I want to place all my Async code into one class for its respective needs. My quesiotn though is if i need to return a type back to the class that calls the Async method how can I return a value? Also is this the best practice?