这是错误日志:
03-07 11:33:07.474: E/AndroidRuntime(5612): FATAL EXCEPTION: main
03-07 11:33:07.474: E/AndroidRuntime(5612): android.view.WindowManager$BadTokenException: Unable to add window -- token android.os.BinderProxy@45b69850 is not valid; is your activity running?
03-07 11:33:07.474: E/AndroidRuntime(5612): at android.view.ViewRootImpl.setView(ViewRootImpl.java:567)
03-07 11:33:07.474: E/AndroidRuntime(5612): at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:246)
03-07 11:33:07.474: E/AndroidRuntime(5612): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69)
03-07 11:33:07.474: E/AndroidRuntime(5612): at android.app.Dialog.show(Dialog.java:281)
而且我知道这是因为引用错误,我通过 getContext() 方法获取上下文(对话框不在任何活动中)
所以我不能使用 XXXActivity.this 来获得正确的上下文。所以我该怎么做?