I usually use AsyncTask in the same class with the caller, but now I want to call asyntask from different class using interface class,I want to get value from onProgressUpdate call from another clas, this my asynctask class..
class UploadFileToServer extends AsyncTask<String, Integer, String> implements DialogInterface.OnCancelListener {
private String url;
private File file;
ShareProgress shareProgres;
SharePosExecute sharePosExecute;
public UploadFileToServer(String url, String file) {
this.url = url;
this.file = new File(file);
}
@Override
protected void onPreExecute() {
}
@Override
protected String doInBackground(String... v) {
//place code of upload file to server,run very well...
return responseFromServer;
}
@Override
protected void onProgressUpdate(Integer... progress) {
Log.v("progress",progress[0]+""); //this work well
shareProgres.progressUpdate(progress[0]); //I get error in here
}
@Override
protected void onPostExecute(String response) {
sharePosExecute.posExecute(response); // i also get error in here
}
@Override
public void onCancel(DialogInterface dialog) {
cancel(true);
// dialog.dismiss();
}
}
in my activity class
public class myActivity extends SherlockFragmentActivity implements ShareProgress,SharePosExecute {
@Override
public void progressUpdate(int progress) {
Log.i("progress in myactivity",progress+""); //i want to this code work.
}
@Override
public void posExecute(String output) {
Log.i("processFinish myActivity",output);
}
}
I use interface class for comunicated with diferent class, here my interface code
public interface ShareProgress {
void progressUpdate(int progress);
}
how do i fix this,may be there is another ways for this, please help
thanks