Android – 错误 – IllegalArgumentException:添加窗口后无法更改窗口类型

Android – 错误 – IllegalArgumentException:添加窗口后无法更改窗口类型,第1张

概述我正在调试一个 Android应用程序(不幸的是由别人写的).该应用程序具有持续1秒的启动活动,然后使用意图转换为登录页面活动.该应用程序运行正常,直到我注意到未在清单文件中设置targetSDKVersion.我把它设置为18.然后当我在模拟器中运行应用程序时,应用程序崩溃,我在logcat中看到以下错误: 10-24 06:14:26.840: E/AndroidRuntime(2457): 我正在调试一个 Android应用程序(不幸的是由别人写的).该应用程序具有持续1秒的启动活动,然后使用意图转换为登录页面活动.该应用程序运行正常,直到我注意到未在清单文件中设置targetSDKVersion.我把它设置为18.然后当我在模拟器中运行应用程序时,应用程序崩溃,我在logcat中看到以下错误:

10-24 06:14:26.840: E/AndroIDRuntime(2457): FATAL EXCEPTION: main10-24 06:14:26.840: E/AndroIDRuntime(2457): java.lang.IllegalArgumentException: Window type can not be changed after the window is added.10-24 06:14:26.840: E/AndroIDRuntime(2457):     at androID.os.Parcel.readException(Parcel.java:1435)10-24 06:14:26.840: E/AndroIDRuntime(2457):     at androID.os.Parcel.readException(Parcel.java:1385)10-24 06:14:26.840: E/AndroIDRuntime(2457):     at androID.vIEw.Iwindowsession$Stub$Proxy.relayout(Iwindowsession.java:835)10-24 06:14:26.840: E/AndroIDRuntime(2457):     at androID.vIEw.VIEwRootImpl.relayoutwindow(VIEwRootImpl.java:5034)10-24 06:14:26.840: E/AndroIDRuntime(2457):     at androID.vIEw.VIEwRootImpl.performTraversals(VIEwRootImpl.java:1399)10-24 06:14:26.840: E/AndroIDRuntime(2457):     at androID.vIEw.VIEwRootImpl.doTraversal(VIEwRootImpl.java:1004)10-24 06:14:26.840: E/AndroIDRuntime(2457):     at androID.vIEw.VIEwRootImpl$TraversalRunnable.run(VIEwRootImpl.java:5481)10-24 06:14:26.840: E/AndroIDRuntime(2457):     at androID.vIEw.Choreographer$CallbackRecord.run(Choreographer.java:749)10-24 06:14:26.840: E/AndroIDRuntime(2457):     at androID.vIEw.Choreographer.doCallbacks(Choreographer.java:562)10-24 06:14:26.840: E/AndroIDRuntime(2457):     at androID.vIEw.Choreographer.doFrame(Choreographer.java:532)10-24 06:14:26.840: E/AndroIDRuntime(2457):     at androID.vIEw.Choreographer$FramedisplayEventReceiver.run(Choreographer.java:735)10-24 06:14:26.840: E/AndroIDRuntime(2457):     at androID.os.Handler.handleCallback(Handler.java:730)10-24 06:14:26.840: E/AndroIDRuntime(2457):     at androID.os.Handler.dispatchMessage(Handler.java:92)10-24 06:14:26.840: E/AndroIDRuntime(2457):     at androID.os.Looper.loop(Looper.java:137)10-24 06:14:26.840: E/AndroIDRuntime(2457):     at androID.app.ActivityThread.main(ActivityThread.java:5103)10-24 06:14:26.840: E/AndroIDRuntime(2457):     at java.lang.reflect.Method.invokeNative(Native Method)10-24 06:14:26.840: E/AndroIDRuntime(2457):     at java.lang.reflect.Method.invoke(Method.java:525)10-24 06:14:26.840: E/AndroIDRuntime(2457):     at com.androID.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)10-24 06:14:26.840: E/AndroIDRuntime(2457):     at com.androID.internal.os.ZygoteInit.main(ZygoteInit.java:553)10-24 06:14:26.840: E/AndroIDRuntime(2457):     at dalvik.system.NativeStart.main(Native Method)

应用程序在显示启动画面后以及加载登录页面活动之前立即崩溃.以下块显示了splash活动中的相关代码块.

启动活动

private Thread mSplashThread;    @OverrIDe    public voID onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentVIEw(R.layout.splash);    final SplashScreenActivity sPlashScreen = this;           mSplashThread =  new Thread(){@OverrIDe        public voID run(){        try {            synchronized(this){                // Wait given period of time or exit on touch                wait(1000);            }        }        catch(InterruptedException ex){                            }        finish();        // Run next activity        Intent intent = new Intent();        intent.setClass(sPlashScreen,LandingPageActivity.class);        startActivity(intent);                         }    };    mSplashThread.start();            }@OverrIDepublic boolean ontouchEvent(MotionEvent evt){    if(evt.getAction() == MotionEvent.ACTION_DOWN)    {    try{        synchronized(mSplashThread){            mSplashThread.notifyAll();            }    }    catch (IllegalArgumentException e){        Log.v("This is it",e.getCause().getMessage());    }}return true;}

现在在调试此问题的所有研究中,我找到了检查以下代码段的建议,但我的应用程序中没有这样的内容:

@OverrIDe    public voID onAttachedToWindow()    {          this.getwindow().setType(WindowManager.LayoutParams.TYPE_KEyguard);        super.onAttachedToWindow();      }
解决方法 问题得到解决.确实在其中一个空基类中出现了“onAttachedToWindow”.删除该覆盖后它起作用了.正如我在原帖中所提到的,我在另一篇文章中遇到了这个解决方案.这是对 post的引用.

但在我的情况下,此代码不在任何面向用户的活动中.这是我的登录页面继承的空白父活动.希望有人在这篇文章后几个小时保存.

总结

以上是内存溢出为你收集整理的Android – 错误 – IllegalArgumentException:添加窗口后无法更改窗口类型全部内容,希望文章能够帮你解决Android – 错误 – IllegalArgumentException:添加窗口后无法更改窗口类型所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1122130.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-29
下一篇2022-05-29

发表评论

登录后才能评论

评论列表(0条)

    保存