windowManager.addView时报错
Caused by: android.view.WindowManager$BadTokenException: Unable to add window -- token null is not valid; is your activity running?
有可能是LayoutParams没有配置type或者type配置错误,可以试试layoutParams.type=WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
经过尝试,发现type =WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;这个值是可以在除activity外正常运行的,其他的试了好几个也不行。所以以后如果能满足需求就直接使用这个type。如果不能满足再尝试其他的吧。这个值是添加的view会在应用的上表层显示。