I am creating an AlertDialog in my activity onResume with the following
LayoutInflater li = LayoutInflater.from(this) ;
View view = li.inflate(R.layout.welcome,null);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Welcome to StreamHold");
welcome = builder.create();
The dialog has an exit button. When clicked the following code executes in
the onClick listener:
and normally the dialog disappears. This fails, however, if while the
dialog box is displayed I press the power button to blank the display and
then press it a second time to restore. In this case, the dismiss fails.
Repeated pressing of the exit button will re-execute the dismiss(), but the
box remains visible and the exit button is still active. I have attempted
various workarounds: replacing dismiss() with cancel(); adding hide();
requesting focus for the underlying window; various experiments with
invalidating the underlying layout and the layout of the dialog box.. None
of these have worked. If, however, you tap the exposed portion of the
underlying window or press the back button the dialog box does disappear.
Am I doing something wrong here, or is this a known issue?
I have reproduced this on a Nexus 7 running 4.1.1.