Ah, it's crashing there because when you change it to showDialog(0) , right after it returns the AlertDialog, it's trying to call _progressDialog which hasn't been initialized yet (because that gets initialized in case 1 of onCreateDialog).
Some simple ducttape:
In the initial variable declarations, right after
Code:
private Handler _progressHandler;
Shove in:
Code:
//DUCTTAPE
private boolean inProgressMode = false;
For the onCreate():
Code:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button btn = (Button) findViewById(R.id.btn_dialog);
btn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
showDialog(0);
//DUCTTAPE Conditional
if (inProgressMode) {
_progress = 0;
_progressDialog.setProgress(0);
_progressHandler.sendEmptyMessage(0);
} //End the DUCTTAPE
}
});
And then in onCreateDialog, right after "case 1:", put
Code:
inProgressMode = true; //DUCTTAPE Trigger