我正在使用新线程来检查身份验证并打开适当的活动。
这些是我的代码段,用于解释我的疑问。 (这些代码工作正常,但我担心性能)
@Override
protected void onStart() {
super.onStart();
new Thread(new Runnable() {
@Override
public void run() {
// Check if user is signed in (non-null) and update UI accordingly.
FirebaseUser currentUser = mAuth.getCurrentUser();
updateUI(currentUser);
}
}).start();
}
private void updateUI(FirebaseUser currentUser) {
if (currentUser != null) {
openMainActivity();
} else {
openLoginActivity();
}
}
private void openLoginActivity() {
Intent loginIntent = new Intent(SplashActivity.this, LoginActivity.class);
startActivity(loginIntent);
SplashActivity.this.finish();
}
我的问题是