自定义对话框 提示:Unable to add window token null is not for an application

这是因为在new Dialog(context);的时候传入的context是通过getApplicationContext()获得的,这样就会报错。

把context的获得方式改为MainActivity.this就好了。

原文地址:https://www.cnblogs.com/qlong8807/p/5167560.html