Android,LogCat 显示此错误 : "Deprecated Thread methodes are not supported", 这是什么?

标签 android multithreading deprecated ddms

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

运行程序后,屏幕截图将显示 5 秒,然后显示菜单( Activity 名称为 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();
        }

enter image description here

最佳答案

您收到此异常是因为 Thread 的方法 stop()stop(Throwable)已弃用,切勿使用。

Because stopping a thread in this manner is unsafe and can leave your application and the VM in an unpredictable state.

关于Android,LogCat 显示此错误 : "Deprecated Thread methodes are not supported", 这是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6831580/

相关文章:

r - 如何替换矢量整理器

php - 升级到 PHP 5.3 后,如何通过将 session_unregister 替换为 $SESSION[] 来避免弃用警告?

android - AIDL 找不到自定义声明的接口(interface)

java - 单击时微调器崩溃

ios - DISPATCH_QUEUE_CONCURRENT和全局并发调度队列之间有什么区别

java - 如何在 JavaFX 线程之外更新 TableView 项目

polymer - 修复不赞成使用的文件

android - 任务 ':google_api_headers:compileDebugKotlin' 执行失败

android - 无法从另一个应用程序读取 SharedPreferences

Java:同时移动对象