Skip to content

Instantly share code, notes, and snippets.

@aasumitro
Last active October 11, 2017 03:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aasumitro/5e7bd3f2e17be88b7f1684ec595e0393 to your computer and use it in GitHub Desktop.
Save aasumitro/5e7bd3f2e17be88b7f1684ec595e0393 to your computer and use it in GitHub Desktop.
Splash Screen with Firebase Auth
public class SplashScreen extends AppCompatActivity {
private static int SPLASH_TIME_OUT = 3000;
private FirebaseAuth mAuth;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash_screen);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
// This method will be executed once the timer is over
// Start app main activity
// firebase Auth
// Get Firebase auth instance (user still login)
mAuth = FirebaseAuth.getInstance();
if (mAuth.getCurrentUser() != null) {
startActivity(new Intent(SplashScreen.this, MainActivity.class));
finish();
}else {
// user has logout
startActivity(new Intent(SplashScreen.this, LoginActivity.class));
finish();
}
// close this activity
finish();
}
}, SPLASH_TIME_OUT);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment