Skip to content Skip to sidebar Skip to footer

Alert Dialog Pops Up Even After Dismissing It

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 t

Solution 1:

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

case1:
               returnnewAlertDialog.Builder(this)

               .setMessage("Failed")
               .setIcon(R.drawable.failure)
               .setPositiveButton("OK",
                       newDialogInterface.OnClickListener() {

                        @OverridepublicvoidonClick(DialogInterface dialog, int which) {

                            dialog.dismiss();

                          return;
                        }
                    }).create();   //Here replaced .show with .create()

Solution 2:

This is just an idea but it seems the issue is that onOrientation is trying to re-draw the activity.

Try something like the following:

You can add this to the activity declaration in the manifest:

android:configChanges="orientation"

so it looks like

<activityandroid:label="@string/app_name"android:configChanges="orientation"android:name=".your.package">

The matter is that the system destroys the activity when a change in the configuration occurs. See ConfigurationChanges.

So putting that in the configuration file avoids the system to destroy your activity. Instead it invokes the onConfigurationChanged(Configuration) method.

Hope this helps.

Post a Comment for "Alert Dialog Pops Up Even After Dismissing It"