I am new to Android and developing a utility UI component which displays dialog box on launch , I want to close the app if user does not make a choice in the dialog box and chooses to press back button. How do I achieve this in dialogFragment? I would not have access to the activity code .
This component is implemented as DialogFragment.
I tried
dialog.setOnDismissListener( new OnDismissListener()
{
@Override
public void onDismiss(DialogInterface dialog)
{
getActivity().finish();
}
});
but this does not close the activity if I press back button.
what is the best practice to implement mandatory dialog box in Android
Thanks in advance