hi,friend you know Android's Activity lifecycle as following: <https://lh3.googleusercontent.com/-TZN_L7z9w3A/UA39seq4q3I/AAAAAAAAAB8/VGNbeMWsSwM/s1600/activity_lifecycle.png> you create the alertdialog in onResume, but when the dialog is showed , the activity will exectutes onPause(), and when you click the exit button ,the activity will exectute the onResume! So you have the problem! On Tuesday, 24 July 2012 08:47:04 UTC+8, Brad Justice wrote: > > I am creating an AlertDialog in my activity onResume with the following > code: > 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"); > builder.setView(view); > welcome = builder.create(); > welcome.show(); > > The dialog has an exit button. When clicked the following code executes in > the onClick listener: > welcome.dismiss(); > 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? > > Thanks, > > Brad Justice > > I have reproduced this on a Nexus 7 running 4.1.1. > >
-- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

