I\'m a bit new with the AsyncTask and ProgressDialog and i\'m getting a null pointer exception error whenever i call new MyTask().execute();
on my button does my ap
nother part that I hope it helps ...if u want to change the text and percentage of progress during the background task u can define a handler
public class MyTask extends AsyncTask
{
private ProgressDialog progressDialog;
private String mstepDescription;
protected int mprogressPercentage;
private String mstepDescription;
protected int mprogressPercentage;
Handler handle = new Handler() {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
progressDialog.setMessage(mstepDescription);
progressDialog.setProgress(mprogressPercentage);
}
};
void Step (String StepDescription, int Progress)
{
mstepDescription = StepDescription;
mprogressPercentage = Progress;
handle.sendMessage(handle.obtainMessage());
}
Protected void onPreExecute()
{
// create dialog here
progress = new ProgressDialog (...);
progress.setMessage(...);
progress.show();
}
protected void onPostExecute(...){
// dismiss dialog here
progress.dismiss();
}
@Override
protected Void doInBackground(Void... params)
{
// do somthing
Step("...", 40);
// do something else
}
}