How to use one AsyncTask Class to apply different Activity in Android
<p>I have a AsyncTask class that connect to web service to get something and then print to the screen.<br>
Here is my code:</p>

<pre><code>public class GetCreditAsyncTask extends AsyncTask&lt;Object, Boolean, String&gt;{
   private MainActivity callerActivity;
   private String credit;
   public GetCreditAsyncTask(Context context){
        callerActivity = (MainActivity )context;
    }
   @Override
    protected String doInBackground(Object... params) { 
         .....//do something and get the credit
}
   @Override
    protected void onPostExecute(String response) {
          callerActivity.txtView.setText(credit);
   }


}
</code></pre>

<p>It works perfect but now, I have one more Activity <code>ProfileActivity</code><br>
which also want to use <code>GetCreditAsyncTask</code> to get the credit and print it to the <code>txtView</code>,<br>
but at the begining of <code>GetCreditAsyncTask</code>, I cast the <code>callerActivity</code> to <code>MainActivity</code>.<br>
The question is how to just use one AsyncTask class so that I can call it and get the credit. </p>
