一般的对话框在activity中都能显示,那么在frameworks中去显示就会提示这样的错误
08-13 04:49:06.544 9066 9066 E AndroidRuntime: Caused by: android.view.WindowManager$BadTokenException: Unable to add window -- token null is not valid; is your activity running?
只有一行代码就能解决
if (!(mContext instanceof Activity)) {mDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);}
type是你对话框显示的层级。