Advertisement
obernardovieira

[Android] Wait 5sec and go another page

Jul 22nd, 2016
388
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.78 KB | None | 0 0
  1. //MainActivity.java
  2.  
  3. public class MainActivity extends AppCompatActivity {
  4.  
  5.     @Override
  6.     protected void onCreate(Bundle savedInstanceState) {
  7.         super.onCreate(savedInstanceState);
  8.         setContentView(R.layout.activity_main);
  9.  
  10.  
  11.         final Intent intent = new Intent(this, Login.class);
  12.         Timer t = new Timer();
  13.         TimerTask tt = new TimerTask() {
  14.             @Override
  15.             public void run() {
  16.                 startActivity(intent);
  17.             }
  18.         };
  19.         t.schedule(tt, 5000);
  20.     }
  21. }
  22.  
  23.  
  24.  
  25.  
  26. //Login.java
  27.  
  28. public class Login extends AppCompatActivity {
  29.  
  30.     @Override
  31.     protected void onCreate(Bundle savedInstanceState) {
  32.         super.onCreate(savedInstanceState);
  33.         setContentView(R.layout.activity_login);
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement