我正在做一个项目,我需要显示主页,当主页显示,之后或继续3到5秒,我的其他欢迎自定义对话框显示。但做到这一点,下面的错误发生,但我的应用程序不会停止工作.. LogCat显示这些错误。 应用代码:不支持弃用的线程方法不支持
final Dialog d=new Dialog(Main.this);
d.setContentView(R.layout.SplashScreen);
Thread splashTread = new Thread() {
@Override
public void run() {
try {
d.show();
int waited = 0;
while(_active && (waited < _splashTime)) {
sleep(100);
if(_active) {
waited += 100;
}
}
} catch(InterruptedException e) {
// do nothing
} finally {
d.cancel();
stop();
}
}
};
splashTread.start();
}
@Override
public boolean onTouchEvent(MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
_active = false;
}
return true;
}
在logcat的错误:
12-30 14:54:54.044: E/global(1232): Deprecated Thread methods are not supported.
12-30 14:54:54.044: E/global(1232): java.lang.UnsupportedOperationException.
12-30 14:54:54.044: E/global(1232): at java.lang.VMThread.stop(VMThread.java:85)
12-30 14:54:54.044: E/global(1232): at java.lang.Thread.stop(Thread.java:1280)
12-30 14:54:54.044: E/global(1232): at java.lang.Thread.stop(Thread.java:1247)
12-30 14:54:54.044: E/global(1232): at com.droidnova.android.SplashScreen$1.run(SplashScreen.java:35)
谢谢..它的工作..谢谢先生。 – Dharmik 2011-12-31 07:12:46
我使用处理程序从外面..在放入run()方法时它显示runnable不会被初始化错误 – Dharmik 2011-12-31 07:15:51
你必须在顶部声明Handler作为全局并使用它。 – 2011-12-31 07:17:32