0

我在 android 4.0 + 上收到此错误,也许是 3.0 + 用户。不是 2.3 以下的用户 我该怎么做才能解决这个问题?希望有一个快速的答案,用户抱怨:(

java.lang.UnsupportedOperationException at java.lang.Thread.stop(Thread.java:1076) at java.lang.Thread.stop(Thread.java:1063) at application.application.Splash$1.run(Splash.java:51)

static int destroy = 0;

protected boolean _active = true; 受保护的 int _splashTime = 5000;

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
     super.onCreate(savedInstanceState);



    setContentView(R.layout.splash);


     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("app.app.TABHOST"));
                    stop();
                }
            }
        };
        splashTread.start();





}




public boolean onTouchEvent(MotionEvent event) {
    if (event.getAction() == MotionEvent.ACTION_DOWN) {
        _active = false;
    }
    return true;


}

}

4

1 回答 1

1

当您调用thread.stop()时会引发此异常.. 因为 stop() 已被弃用。因此,您应该尝试另一种方法而不调用 stop 方法。我认为您可以删除 stop 方法..因为一旦线程完成它的功能它处于死状态..所以可以忽略..尝试删除 stop()

于 2012-04-17T19:04:17.427 回答