I am using a activity with a dialog theme in which I don't put positive nor negative buttons. This activity is launched by the receipt of external notifications (Firebase). When I am about to dismiss the dialog, it takes two taps outside the dialog to dismiss. Indeed:
- on the first tap the dialog dismisses, but the screen remains covered by a sort of overshadowing film/glaze (it must be the same "shadow" that appears when a dialog is open);
- on the second tap this sort of shadow disappears, so returning to my initial GUI.
What can I do to avoid tapping twice, dismissing the dialog activity just by one tap? Is there a way to avoid the creation of that shadow covering my GUI, when the dialog activity gets created?
I think my issue is different from the one here: AlertDialog does not dismiss, takes twice tap to close. In this latter post, what is remarked is that the methods setPositiveButton() and setNegativeButton() have an implicit call to the dialog dismissal, that is not what I am trying to figure out. I simply receive a notification, this notification gets turned into an activity with dialog theme, and to dismiss it i need two taps, whereas I would like to have just one tap to dismiss. This is my Activity:
public class NotificationDialogActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = getIntent();
showDialog(this, intent);
}
private void showDialog(Context context, @NonNull Intent intent) {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(intent.getStringExtra("title"));
builder.setMessage(intent.getStringExtra("text"));
builder.create().show();
}
}