Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8546385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:00:26+00:00 2026-06-11T13:00:26+00:00

I have come across a typical problem and it seems strange to me. Details

  • 0

I have come across a typical problem and it seems strange to me. Details are something like this – On the activity in my app, there are edittexts and submit button. After filling the data in the edittexts, user can click submit button. After clicking submit button, based on the values that are entered by the user, either of the two alert dialogs are shown. One is success and the other one is failed.

The thing is when the user enters invalid data and clicks submit button, the failed alert dialog gets opened. I have a button(OK) on the failed alert dialog, after clicking it I wrote dialog.dismiss(); to make it disappear, so that user can recheck the data and can modify. But the problem is while rechecking & modifying the data if he changes the orientation, then again the failed alert dialog is popping up even without clicking submit button. Please suggest.

Extra Details(though probably not necessary for this problem): While changing orientation the activity is recreated. So, I am saving the current data in the onSavedInstanceState() and retrieving it in onCreate() method to set back the values in the edittexts. Everything works fine, but once clicking on submit button, the respective alert dialog appears. Then after changing orientation the dialog is again popping up. I am sure that I wrote showDialog(1); in the onClick() method but then again why control is going back into onClick and showing that alert dialog even without clicking.

protected Dialog onCreateDialog(int id) {
   switch(id){                 
      case 0:          
        return new AlertDialog.Builder(this)
                      .setMessage("Success!") 
                      .setIcon(R.drawable.success)
                      .setPositiveButton("OK",
                      new DialogInterface.OnClickListener() {
                         @Override
                         public void onClick(DialogInterface dialog, int which) {
                            dialog.dismiss();                   
                         }
                      }).show();
       case 1:
           return new AlertDialog.Builder(this)
                      .setMessage("Failed")
                      .setIcon(R.drawable.failure)
                      .setPositiveButton("OK",
                       new DialogInterface.OnClickListener() {

                           @Override
                           public void onClick(DialogInterface dialog, int which) {
                              dialog.dismiss();     
                              return;
                           }
                        }).show();   
           }
           return null;
       }

Here is the method that makes alert dialog show.

public void onClick(View v) {
   switch (v.getId()) {    
      //Here there are other cases too.
      case R.id.submit:
        getEditTexts();
        validator();
      break;
   }
}

public void validator() {              
    if(generator.receiveVal(0,0,sudo)) {
       showDialog(0);
     }
    else if(!generator.receiveVal(0,0,sudo)) {
       showDialog(1);
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T13:00:27+00:00Added an answer on June 11, 2026 at 1:00 pm

    Just try replacing .create() in the place of .show(). In your case like this:

    case 1:
                   return new AlertDialog.Builder(this)
    
                   .setMessage("Failed")
                   .setIcon(R.drawable.failure)
                   .setPositiveButton("OK",
                           new DialogInterface.OnClickListener() {
    
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
    
                                dialog.dismiss();
    
                              return;
                            }
                        }).create();   //Here replaced .show with .create()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have come across a strange problem which I would like to get your
I have come across a strange problem. MY app has been localized to support
I have come across a problem with binding to a PasswordBox . It seems
I have come across this problem a few times and never been able to
I have come across this problem before and I have never understood the reasoning
I have come across a somewhat annoying problem during a project. I created this
I have come across a few references regarding the JVM/JIT activity where there appears
I have come across what seems like a really annoying bug running my C++
I have come across an annoying problem. I have made a system and now
I have come across loop-unrolling but what other types of compiler optimization are there

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.