Thanks to Reuben, it works 100% as expected.
Here is what I have now:
import android.content.Context;
import android.os.AsyncTask;
public abstract class KAsyncTask<Params, Progress, Result> extends AsyncTask<Params, Progress, Result> {
public Context context;
public KAsyncTask<Params, Progress, Result> setContext(Context c){
this.context = c;
return this;
}
}
And here is how I use it:
new KAsyncTask<Void, Void, Void>() {
@Override
protected void onPreExecute() {
Toast.makeText(context, "Connecting to Server...", Toast.LENGTH_LONG).show();
}
@Override
protected void onPostExecute(Void result) {
Toast.makeText(context, "Responce Recieved.", Toast.LENGTH_LONG).show();
}
@Override
protected Void doInBackground(Void... params) {
return null;
}
}.setContext(this).execute();
.
,
EZFrag