嗨,我是 Android 的新手,请帮帮我,我正在尝试使用以下代码为我的启动画面设置时间,但应用程序没有安装并返回 NULL。我使用的是安卓 4.1.2
public class SplashActivity extends Activity {
//how long until we go to the next 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.activity_splash);
// thread for displaying the SplashScreen
Thread splashTread = new Thread() {
@SuppressWarnings("deprecation")
@Override
public void run() {
try {
int waited = 0;
while(_active && (waited < _splashTime)) {
sleep(100);
if(_active) {
waited += 100;
}
}
} catch(InterruptedException e) {
// do nothing
} finally {
stop();
}
}
};
splashTread.start();
}
}