Android   发布时间:2022-03-31  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了启动画面启动时出现java.lang.UnsupportedOperationException大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

当我的启动屏幕启动时,我在logcat中得到此错误

11-06 02:36:45.450: E/global(4184): Deprecated Thread methods are not supported.
11-06 02:36:45.450: E/global(4184): java.lang.UnsupportedoperationException
11-06 02:36:45.450: E/global(4184):     at java.lang.VMThread.stop(VMThread.java:85)
11-06 02:36:45.450: E/global(4184):     at java.lang.Thread.stop(Thread.java:1280)
11-06 02:36:45.450: E/global(4184):     at java.lang.Thread.stop(Thread.java:1247)
11-06 02:36:45.450: E/global(4184):     at com.example.kostas.splash$1.run(splash.java:38)

这是我的课:

public void onCreate(Bundle savedInstanceStatE) {
        super.onCreate(savedInstanceStatE);
        setContentView(R.layout.splash);

        // thread for displaying the SplashScreen
        Thread splashTread = new Thread() {
            @Override
            public void run() {
                try {
                    int waited = 0;
                    while(_active && (waited < _splashTimE)) {
                        sleep(100);
                        if(_activE) {
                            waited += 100;
                        } 
                    }
                } catch(InterruptedException E) {
                    // do nothing
                } finally {
                    finish();
                    startActivity(new Intent("com.example.kostas.main"));
                    stop();
                }
            }
        };
        splashTread.start();
    }
    @Override
    public Boolean onTouchEvent(MotionEvent event) {
        if (event.getAction() == MotionEvent.ACTION_DOWN) {
            _active = false;
        }
        return true;
    }

第38行是stop();

我的应用程序启动没有问题,但我想修复它..我试删除“ stop();”但我也遇到另一个错误.

11-06 02:44:56.321: E/(32599): onResume() check 0
11-06 02:44:56.321: E/(32599): onResume() check 1
11-06 02:44:56.321: E/Launcher(32599): setWindowOpaque()
11-06 02:44:56.341: E/(32599): onResume() check 2, mRestoring : false
11-06 02:44:56.341: E/(32599): onResume() check 3
11-06 02:44:56.341: E/(32599): onResume() check 4
11-06 02:44:56.345: E/(32599): onResume() check 5

谢谢

解决方法:

答案是在错误消息中:不建议使用Thread.stop(),Android不支持不建议使用的方法.

也许您可以尝试在onCreate中使用Thread.sleep()来代替超时.

大佬总结

以上是大佬教程为你收集整理的启动画面启动时出现java.lang.UnsupportedOperationException全部内容,希望文章能够帮你解决启动画面启动时出现java.lang.UnsupportedOperationException所遇到的程序开发问题。

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

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: