我正在为应用程序制作 SplashScreen ...当应用程序启动时,它会启动 LoadingActivity ...睡眠 3 秒,完成();然后启动 MainActivity。Splash 用于更新数据库。如果数据库已经更新,无论如何我都希望启动 3 秒。
我正在使用以下代码:
protected void onPostExecute(Void result) {
super.onPostExecute(result);
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
Intent intent = new Intent(LoadingActivity.this, MainActivity.class);
startActivity(intent);
finish();
}
}
这是一个坏习惯吗?为什么?该应用程序在 AVD 中运行良好。