Advertisement
Putra-Kun123

MainActivity.java

Feb 23rd, 2020
8,733
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. package notes.bapakkau;
  2.  
  3. import android.app.Activity;
  4. import android.content.Intent;
  5. import android.os.Bundle;
  6. import android.os.Handler;
  7.  
  8. public class MainActivity extends Activity {
  9. private boolean backbtnPress;
  10. private static final int SPLASH_DURATION = 4000;
  11. private Handler myHandler;
  12.  
  13.  
  14. /** Called when the activity is first created. */
  15.  
  16. @Override
  17. protected void onCreate(Bundle savedInstanceState) {
  18. // TODO Auto-generated method stub
  19. super.onCreate(savedInstanceState);
  20. setContentView(R.layout.main);
  21.  
  22. myHandler = new Handler();
  23.  
  24. myHandler.postDelayed(new Runnable() {
  25.  
  26. public void run() {
  27. // TODO Auto-generated method stub
  28. finish();
  29.  
  30. if(!backbtnPress)
  31. {
  32. Intent intent = new Intent(MainActivity.this,LoginActivity.class);
  33. MainActivity.this.startActivity(intent);
  34. }
  35.  
  36. }
  37. }, SPLASH_DURATION);
  38. }
  39.  
  40. @Override
  41. public void onBackPressed() {
  42. // TODO Auto-generated method stub
  43. backbtnPress = true;
  44. super.onBackPressed();
  45. }
  46.  
  47. }
  48. // ig harymalau
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement