我已经制作了适用于1.6及更高版本的应用程序,但是一旦我将手机更新到4.0.4,它就会给我以下错误,不幸的是,测试已经停止,它根本不会运行。有什么理由可能发生这种情况?也许我需要在编码上改变一些东西以使它适用于新版本? 包com.droidnova.android;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.MotionEvent;
public class SplashScreen extends Activity {
protected boolean _active = true;
protected int _splashTime = 5000;
/** Called when the activity is first created. */
@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("com.droidnova.android.splashscreen.MyApp"));
stop();
}
}
};
splashTread.start();
}
@Override
public boolean onTouchEvent(MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
_active = false;
}
return true;
}
}
答案 0 :(得分:1)
一个疯狂的猜测是你在另一个线程中调用finish()和startActivity()而不是UI线程。使用asynctask而不是线程或使用Activity.runOnUiThread()。是的,logcat会有所帮助。