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

  • Home
  • SEARCH
  • 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 7746807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:22:28+00:00 2026-06-01T10:22:28+00:00

I get this error sometimes reported when creating a dialog, i haven’t experienced the

  • 0

I get this error sometimes reported when creating a dialog, i haven’t experienced the error myself and it doesnt seem to happen for every user since i am getting data send with the dialog. I have tested android 2.2.This is the code.

private static final int DIALOG_CONTEST_ENTRY = 939321;

showDialog(DIALOG_CONTEST_ENTRY);

protected Dialog onCreateDialog(int id) {

    switch (id) {
    case DIALOG_CONTEST_ENTRY: 
        final Dialog dialog = new Dialog(this);
        dialog.setContentView(R.layout.contest_entry_dialog);
        dialog.setTitle(getString(R.string.ContestEntryDialogTitle));
        dialog.setCanceledOnTouchOutside(true);
        TextView text = (TextView) dialog.findViewById(R.id.contest_text); 
        text.setText(getString(R.string.ContestEntryDialogText));
        Button sendButton = (Button) dialog.findViewById(R.id.ButtonSend);
        Button cancelButton = (Button) dialog.findViewById(R.id.ButtonCancel);
        final EditText name = (EditText) dialog.findViewById(R.id.editName);
        final EditText email = (EditText) dialog.findViewById(R.id.editEmail);
        final TextView score = (TextView) dialog.findViewById(R.id.textScore);

        final Prefs prefs = new Prefs(xxxActivity.this);

        name.setText(prefs.ReadString("Name"));
        email.setText(prefs.ReadString("Email"));
        score.setText("Score: " + scoreCurrent);

        sendButton.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                                            //Send form
                    dialog.dismiss();
                }
            }
        });
        cancelButton.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                dialog.dismiss();
            }
        });
        dialog.show();
        return dialog;
    default:
        break;
    }
    return super.onCreateDialog(id);
}


<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="match_parent"
  android:layout_height="match_parent" android:orientation="vertical" android:padding="10dp" android:background="#FFF">

<TextView
    android:id="@+id/contest_text"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/ContestEntryDialogText"
    android:textColor="#000" />

<EditText
    android:id="@+id/editName"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:inputType="textPersonName" android:hint="Enter Name"/>

<EditText
    android:id="@+id/editEmail"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:inputType="textEmailAddress" android:hint="Enter Email">

    <requestFocus />
</EditText>
<TextView
    android:id="@+id/textScore"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Score: " android:textSize="20dp"/>

<LinearLayout
    android:id="@+id/linearLayout1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <Button
        android:id="@+id/ButtonSend"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Send" />

    <Button
        android:id="@+id/ButtonCancel"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Cancel" />

</LinearLayout>

  • 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-01T10:22:29+00:00Added an answer on June 1, 2026 at 10:22 am

    After experiencing this same issue (and finding that calling removeDialog from within onPause doesn’t work reliably), I developed a workaround that seems to function (although it’s admittedly a hack).

    As seen in the grepcode link posted by antslava, in method performRestoreInstanceState, onRestoreInstanceState is called right before restoreManagedDialogs and is passed the same instance of Bundle savedInstanceState.

    final void performRestoreInstanceState(Bundle savedInstanceState) {
        onRestoreInstanceState(savedInstanceState);
        restoreManagedDialogs(savedInstanceState);
    }
    

    Thus, there is opportunity to modify the Bundle savedInstanceState that is passed to restoreManagedDialogs from within the onRestoreInstanceState method.

    To prevent any and all managed dialogs from being restored, one could implement onRestoreInstanceState in the following way:

    // This same variable is defined as private in the Activity class. I need
    // access to it, so I redefine it here.
    private static final String SAVED_DIALOGS_TAG = "android:savedDialogs";
    
    @Override
    protected void onRestoreInstanceState(Bundle savedInstanceState) {
        super.onRestoreInstanceState(savedInstanceState);
        final Bundle b = savedInstanceState.getBundle(SAVED_DIALOGS_TAG);
        if (null != b) {
            savedInstanceState.remove(SAVED_DIALOGS_TAG);
        }
    }
    

    This causes the Bundle referenced by key “android:savedDialogs” to be removed from Bundle savedInstanceState, which subsequently causes the call to restoreManagedDialogs to immediately return when it finds that this key cannot be found:

    private void restoreManagedDialogs(Bundle savedInstanceState) {
        final Bundle b = savedInstanceState.getBundle(SAVED_DIALOGS_TAG);
        if (b == null) {
            return;
        }
        ...
    }
    

    This will cause onCreateDialog to not be called while restoring the Activity, effectively “hiding” any dialogs, thus preventing the scenario where one must return null from onCreateDialog from occurring.

    This isn’t a ‘one size fits all’ solution, but given my requirements it seems to fit the bill. By reviewing the code in grepcode for several platform versions (1.6, 2.1, 2.2, 2.2.2, and 4.0.3), it appears that this solution should work consistently given these existing implementations.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I get this error sometimes on a session scoped component, still haven't figured out
Sometimes users mistakenly redirected to ?Process=ViewImages&PAGEID=. When this happens, they get the following error.
When I transfer a file about 50Mb over HTTP sometimes I get this error:
I get this error randomly, sometimes it shows and sometimes not! The Error: Now
Sometimes in execution I get this error message in VS2010 when trying to free
I get this error sometimes, Catchable fatal error: Object of class stdClass could not
Sometimes I get this error when extracting youtube videos by json, here's an example:
The issue is that sometimes I get this error in Google Chrome when I
Sometimes I get a broken background in Chrome. I do not get this error
I get this error sometimes invalid byte sequence in UTF-8 when I read contents

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.