Last active
October 11, 2017 03:50
-
-
Save aasumitro/5e7bd3f2e17be88b7f1684ec595e0393 to your computer and use it in GitHub Desktop.
Splash Screen with Firebase Auth
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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