Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
problem with AlertDialog and power button
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Brad Justice  
View profile  
 More options Jul 23 2012, 8:47 pm
From: Brad Justice <bradleypjust...@gmail.com>
Date: Mon, 23 Jul 2012 17:47:04 -0700 (PDT)
Local: Mon, Jul 23 2012 8:47 pm
Subject: problem with AlertDialog and power button

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 must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Justin Anderson  
View profile  
 More options Jul 23 2012, 9:44 pm
From: Justin Anderson <magouyaw...@gmail.com>
Date: Mon, 23 Jul 2012 19:44:05 -0600
Local: Mon, Jul 23 2012 9:44 pm
Subject: Re: [android-developers] problem with AlertDialog and power button

Try dismissing it in onPause() out it is visible...
On Jul 23, 2012 6:48 PM, "Brad Justice" <bradleypjust...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Justin Anderson  
View profile  
 More options Jul 23 2012, 9:45 pm
From: Justin Anderson <magouyaw...@gmail.com>
Date: Mon, 23 Jul 2012 19:45:04 -0600
Local: Mon, Jul 23 2012 9:45 pm
Subject: Re: [android-developers] problem with AlertDialog and power button

Sorry, that should have said dismiss in onPause() IF it is visible...
On Jul 23, 2012 6:48 PM, "Brad Justice" <bradleypjust...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
曾祥鑫  
View profile  
 More options Jul 23 2012, 9:48 pm
From: 曾祥鑫 <zxxjjfore...@gmail.com>
Date: Mon, 23 Jul 2012 18:48:32 -0700 (PDT)
Local: Mon, Jul 23 2012 9:48 pm
Subject: Re: problem with AlertDialog and power button

hi,friend
you know Android's Activity lifecycle as following:

<https://lh3.googleusercontent.com/-TZN_L7z9w3A/UA39seq4q3I/AAAAAAAAAB...>
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!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
TreKing  
View profile  
 More options Jul 24 2012, 1:59 am
From: TreKing <treking...@gmail.com>
Date: Tue, 24 Jul 2012 00:59:24 -0500
Local: Tues, Jul 24 2012 1:59 am
Subject: Re: [android-developers] problem with AlertDialog and power button

On Mon, Jul 23, 2012 at 7:47 PM, Brad Justice <bradleypjust...@gmail.com>wrote:

> The dialog has an exit button.

First suggestion would be to replace your layout button that calls dismiss
with a standard dialog button that does this automatically. See if that
helps.

--------------------------------------------------------------------------- ----------------------
TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago
transit tracking app for Android-powered devices


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Brad Justice  
View profile  
 More options Jul 24 2012, 11:40 am
From: Brad Justice <bradleypjust...@gmail.com>
Date: Tue, 24 Jul 2012 08:40:50 -0700 (PDT)
Local: Tues, Jul 24 2012 11:40 am
Subject: Re: [android-developers] problem with AlertDialog and power button

Yes, that was the problem. Your suggestion works perfectly.

Thanks all for your assistance.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »