public class SpalshScreen extends AppCompatActivity {
FirebaseUser currentUser;
private FirebaseAuth mAuth;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_spalsh_screen);
mAuth = FirebaseAuth.getInstance();
if (mAuth != null) {
currentUser = mAuth.getCurrentUser();
}
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
FirebaseUser user = mAuth.getCurrentUser();
if (user == null) {
Intent intent = new Intent(SpalshScreen.this, LoginActivity.class);
startActivity(intent);
finish();
} else {
Intent mainIntent = new Intent(SpalshScreen.this, DashboardActivity.class);
mainIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(mainIntent);
finish();
}
}
}, 1000);
}
}
Asked
Active
Viewed 246 times
-1

ADM
- 20,406
- 11
- 52
- 83

Manav Nagpal
- 1
- 2
1 Answers
1
Try with the following code. Only the parameterless constructor is deprecated, now specify the Looper in the constructor via the Looper.getMainLooper() method.
new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
@Override
public void run() {
}
}, 1000);

Dharmender Manral
- 1,504
- 1
- 6
- 7