2

运行程序后,Logcat 显示一些错误(图片)。但是在该程序运行并正常工作之后。我不明白问题出在哪里。

运行程序后,屏幕截图将显示 5 秒钟,然后显示该菜单(活动名称为 Scroll_View)。现在,LogCat 显示错误。但是,当我单击每个按钮时,它可以正常工作,没有粗鲁或其他任何东西。

那很重要么?

这是线程的代码:

protected boolean _active = true;
    protected int _splashTime = 5000;
    @Override
        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("mobilesoft.asia.malaysia_directory.SplashScreen.Scroll_View"));
                        stop();
                    }
                }
            };
            splashTread.start();
        }

在此处输入图像描述

4

2 回答 2

5

您收到此异常是因为 Thread 的方法stop()stop(Throwable)已弃用且永远不应使用。

因为以这种方式停止线程是不安全的,并且会使您的应用程序和 VM 处于不可预测的状态。

于 2011-07-26T14:30:06.960 回答
2

屏幕截图表明您正在调用 SplashScreen.java 类中的 Thread.stop()(第 35 行)。Thread.stop()已经被弃用了一段时间,因为它们很旧、不安全并且会对 JVM 产生负面影响(http://download.oracle.com/javase/1.4.2/docs/guide/misc/threadPrimitiveDeprecation.html),并且显然,Dalvik VM 不再支持这些线程方法。您应该能够Thread.stop()用其他东西替换调用 - 该链接有一些很好的例子,说明您应该如何做而不是调用这些方法。

于 2011-07-26T14:33:26.577 回答