当我的初始屏幕启动时,我在 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,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8024434/