このnullポインタ例外が発生するのはなぜですか。これが私のコードです。doInBackgroundメソッドからpublishProgressを最初に実行した後、OnProgressUpdateメソッドで例外が発生します。
private class ScanVideoTask extends AsyncTask<String, Integer, String> {
private AsyncTaskCompleteListener<String> callback;
private Context context;
private String resultOutput;
private ProgressDialog mProgressDialog;
public ScanVideoTask(AsyncTaskCompleteListener<String> cb) {
this.callback = cb;
}
protected String doInBackground(String... args) {
// Get the URI of the video path & display it for a short period.
String filename = args[0];
int i= 0;
while(i < 1000000)
{
i++;
int progressPercentage = (int)(((float)i/(float)1000000) * (float)100);
publishProgress(progressPercentage);
}
return "ok";
}
protected void onProgressUpdate(Integer... progress) {
mProgressDialog.setProgress(progress[0]);
}
protected void onPreExecute() {
super.onPreExecute();
showDialog(DIALOG_DOWNLOAD_PROGRESS);
}
protected void onPostExecute(String result) {
System.out.println("on Post execute called" + result);
dismissDialog(DIALOG_DOWNLOAD_PROGRESS);
callback.onTaskComplete(result);
}
}
これが私のonCreateDialogの内容です
@Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case DIALOG_DOWNLOAD_PROGRESS:
mProgressDialog = new ProgressDialog(this);
mProgressDialog.setMessage("Scanning video..");
mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
mProgressDialog.setCancelable(true);
mProgressDialog.show();
return mProgressDialog;
default:
return null;
}
}
私は何が欠けていますか?