16
Android 1.6:“ android.view.WindowManager $ BadTokenException:无法添加窗口-令牌null不适用于应用程序”
我试图打开一个对话框窗口,但是每次我尝试打开它时,都会引发此异常: Uncaught handler: thread main exiting due to uncaught exception android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application at android.view.ViewRoot.setView(ViewRoot.java:460) at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177) at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91) at android.app.Dialog.show(Dialog.java:238) at android.app.Activity.showDialog(Activity.java:2413) 我通过showDialog使用显示器的ID 进行调用来创建它。该onCreateDialog处理程序的日志记录很好,我可以毫无问题地逐步解决它,但是我附上了它,因为似乎我缺少了一些东西: @Override public Dialog onCreateDialog(int id) { Dialog dialog; Context appContext = this.getApplicationContext(); switch(id) { case …