Advertisement
IndahAinur0909

SplashScreenActivity

Jul 27th, 2016
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.24 KB | None | 0 0
  1. package com.codecode.uiappnewsportal;
  2.  
  3. import android.app.Activity;
  4. import android.content.Intent;
  5. import android.graphics.PixelFormat;
  6. import android.os.Bundle;
  7. import android.view.Window;
  8. import android.view.animation.Animation;
  9. import android.view.animation.AnimationUtils;
  10. import android.widget.ImageView;
  11. import android.widget.LinearLayout;
  12.  
  13. /**
  14. * Created by User on 7/26/2016.
  15. */
  16. public class SplashScreenActivity extends Activity {
  17. public void onAttachedToWindow() {
  18. super.onAttachedToWindow();
  19. Window window = getWindow();
  20. window.setFormat(PixelFormat.RGBA_8888);
  21. }
  22.  
  23. /**
  24. * Called when the activity is first created.
  25. */
  26. Thread splashTread;
  27.  
  28. @Override
  29. public void onCreate(Bundle savedInstanceState) {
  30. super.onCreate(savedInstanceState);
  31. setContentView(R.layout.activity_splash_screen);
  32. StartAnimations();
  33. }
  34. private void StartAnimations() {
  35. Animation anim = AnimationUtils.loadAnimation(this, R.anim.alpha);
  36. anim.reset();
  37. LinearLayout l = (LinearLayout) findViewById(R.id.lin_lay);
  38. l.clearAnimation();
  39. l.startAnimation(anim);
  40. anim = AnimationUtils.loadAnimation(this, R.anim.translate);
  41. anim.reset();
  42. ImageView iv = (ImageView) findViewById(R.id.splash);
  43. iv.clearAnimation();
  44. iv.startAnimation(anim);
  45. splashTread = new Thread() {
  46. @Override
  47. public void run() {
  48. try {
  49. int waited = 0;
  50. // Splash screen pause time
  51. while (waited < 3500) {
  52. sleep(100);
  53. waited += 100;
  54. }
  55. Intent intent = new Intent(SplashScreenActivity.this,
  56. MainActivity.class);
  57. intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
  58. startActivity(intent);
  59. SplashScreenActivity.this.finish();
  60. } catch (InterruptedException e) {
  61. // do nothing
  62. } finally {
  63. SplashScreenActivity.this.finish();
  64. }
  65. }
  66. };
  67. splashTread.start();
  68. }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement