I have an AsyncTask that is doing some processing but when it is finished I cannot get it to fire the HandleEvent method af a Handler object (I hope that terminology is correct).
Here is my code:
public class main extends Activity {
/** Called when the activity is first created. */
public Handler mHandler;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// code here to start the background task - all working fine
mHandler = new Handler() {
public void HandleMessage(Message msg) {
Log.v("Handler", "in HandleMessage");
}
};
}
}
final class SendItemToServer extends AsyncTask<Void, Void, Integer> {
@Override
protected Integer doInBackground (Void ... arg0) {
// some code here to connect to my server - all this is working, data is saved on the server
mHandler.sendEmptyMessage(0);
return 0;
}
@Override
protected void onPostExecute(Integer result) {
super.onPostExecute(result);
}
}
The error is on the line mHandler.sendEmptyMessage(0); in the AsyncTask - the error is "mHandler cannot be resolved".
Thanks for any help.
Simon
