Context

是一个方便的API,获取应用程序的数据

Context是Activity的父类-----父类有的方法, 子类一定有, 子类有的方法,父类不一定有
当show一个Dialog时, 必须传Activity对象, 否则会出异常android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
因为Dialog必须依赖Activity为载体才能展示出来, 所以必须将Activity对象传递进去以后在使用Context的时候, 尽量传递Activity对象, 这样比较安全

原文地址:https://www.cnblogs.com/loaderman/p/6430699.html