Created
August 3, 2015 05:17
-
-
Save devrath/d22808cc98b84fef5131 to your computer and use it in GitHub Desktop.
Using isFinish() to avoid bad tolken error
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| android.view.WindowManager$BadTokenException: Unable to add window -- token android.os.BinderProxy@40b47bd8 is not valid; is your activity running? | |
| at android.view.ViewRoot.setView(ViewRoot.java:452) | |
| at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:283) | |
| at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:193) | |
| at android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:118) | |
| at android.view.Window$LocalWindowManager.addView(Window.java:532) | |
| at android.app.Dialog.show(Dialog.java:269) | |
| ... | |
| --------------------------------------------- | |
| runOnUiThread(new Runnable() { | |
| @Override | |
| public void run() { | |
| if(!isFinishing()){ | |
| showDialog ( | |
| new AlertDialog.Builder(MainActivity.this) | |
| .setTitle(R.string.dialogTitle) | |
| .setMessage(R.string.dialogText) | |
| .setCancelable(false) | |
| .setPositiveButton(R.string.txtOk, | |
| new OnClickListener() { | |
| @Override | |
| public void onClick(DialogInterface dialog, int which) { | |
| // whatever... | |
| } | |
| }) | |
| .create() | |
| ); | |
| } | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment