I want my activity, which shows a dialogue, to finish when a user clicks on the positive button of the dialogue. Is this possible. where do I place finish()?
Code that calls the dialogue:
if(name.equals("")) {
DialogFragment newFragment = new NouserFragment();
newFragment.show(getFragmentManager(), "makeprofile"); }
code for dialogue:
public Dialog onCreateDialog(Bundle savedInstanceState) {
// Use the Builder class for convenient dialog construction
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setMessage(R.string.nouseralert)
.setPositiveButton(R.string.add, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
Intent intent = new Intent(getActivity(), Editprofile.class);
startActivityForResult(intent, 0);
}
})
.setNegativeButton(R.string.ignore, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// User cancelled the dialog
}
});
// Create the AlertDialog object and return it
return builder.create();
}