Advertisement
nurrohim11

SplashcScreen

Jul 30th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.46 KB | None | 0 0
  1. package com.izzaweb.bengkel.Ui;
  2.  
  3. import android.content.Intent;
  4. import android.os.Bundle;
  5. import android.support.v7.app.AppCompatActivity;
  6.  
  7. import com.izzaweb.bengkel.MainActivity;
  8. import com.izzaweb.bengkel.R;
  9. import com.izzaweb.bengkel.SessionManager.UserSession;
  10.  
  11. public class SplashscreenAct extends AppCompatActivity {
  12.     UserSession userSession;
  13.     @Override
  14.     protected void onCreate(Bundle savedInstanceState) {
  15.         super.onCreate(savedInstanceState);
  16.         setContentView(R.layout.activity_splashscreen);
  17.         userSession = new UserSession(SplashscreenAct.this);
  18.  
  19.         Thread timerThread = new Thread(){
  20.             public void run(){
  21.                 try {
  22.                     sleep(3000);
  23.                 }
  24.                 catch (InterruptedException e){
  25.                     e.printStackTrace();
  26.                 }finally {
  27.                     if (userSession.isUserLoggedIn()){
  28.                         Intent intent = new Intent(SplashscreenAct.this,MainActivity.class);
  29.                         startActivity(intent);
  30.                     }else{
  31.                         Intent intent = new Intent(SplashscreenAct.this,LoginActivity.class);
  32.                         startActivity(intent);
  33.                     }
  34.                 }
  35.             }
  36.         };
  37.         timerThread.start();
  38.     }
  39.     @Override
  40.     protected void onPause() {
  41.         // TODO Auto-generated method stub
  42.         super.onPause();
  43.         finish();
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement