I\'m using the following code to create my own dialog:
public void ShowMessageDialog(String str){
AlertDialog.Builder builder = new AlertDialog.Builder(t
Intent which is about to fire doesn't wait for your dialog to be canceled. So, right after dialog is shown, new Activity is started. You could accomplish what you want like this:
public void ShowMessageDialog(String str){
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage(str);
builder.setCancelable(false);
builder.setNeutralButton("Ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
Intent intent = new Intent(this,PageViewer.class);
startActivity(intent);
}
});
AlertDialog alert = builder.create();
alert.show();
}
public void test(String str){
ShowMessageDialog("About to start new activity");
}