弹窗时解决错误java.lang.IllegalArgumentException: Window type can not be changed after the window is added.
程序员文章站
2022-03-23 22:47:38
弹窗报错,没有报具体代码信息UncaughtException detected: java.lang.IllegalArgumentException: Window type can not be changed after the window is added. at android.os.Parcel.readException(Parcel.java:1550) at android.os.Parcel.readException(Parcel.java:149...
弹窗报错,没有报具体代码信息
UncaughtException detected: java.lang.IllegalArgumentException: Window type can not be changed after the window is added. at android.os.Parcel.readException(Parcel.java:1550) at android.os.Parcel.readException(Parcel.java:1499) at android.view.IWindowSession$Stub$Proxy.relayout(IWindowSession.java:903) at android.view.ViewRootImpl.relayoutWindow(ViewRootImpl.java:5866) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1791) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1292) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6598) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:800) at android.view.Choreographer.doCallbacks(Choreographer.java:603) at android.view.Choreographer.doFrame(Choreographer.java:572) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:786) at android.os.Handler.handleCallback(Handler.java:815) at android.os.Handler.dispatchMessage(Handler.java:104) at android.os.Looper.loop(Looper.java:194) at android.app.ActivityThread.main(ActivityThread.java:5643) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
这个我是在android5.1系统上报的,我是在后台里 弹窗
那是因为Context 使用了服务的context对象报错
只要把 context 对象改为 application就不报错,或者context是activity不报错
floatWindow.showFloat(mContext, data); //报错
floatWindow.showFloat(mContext.getApplicationContext(), data);//不报错
记录一下
本文地址:https://blog.csdn.net/jinrumorijuesha/article/details/107791180
上一篇: Java代码将图片生成txt文本