- WindowManager$BadTokenException: Unable to add window – token null is not valid; is your activity running?
找到这一句
ViewLayoutParams.type = Constants.WINDOWLAYOUTPARAMS_TYPE;
改为如下
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { windowLayoutParams.type = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY; } else { windowLayoutParams.type = WindowManager.LayoutParams.TYPE_PHONE; }