Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.codecode.uiappnewsportal;
- import android.app.Activity;
- import android.content.Intent;
- import android.graphics.PixelFormat;
- import android.os.Bundle;
- import android.view.Window;
- import android.view.animation.Animation;
- import android.view.animation.AnimationUtils;
- import android.widget.ImageView;
- import android.widget.LinearLayout;
- /**
- * Created by User on 7/26/2016.
- */
- public class SplashScreenActivity extends Activity {
- public void onAttachedToWindow() {
- super.onAttachedToWindow();
- Window window = getWindow();
- window.setFormat(PixelFormat.RGBA_8888);
- }
- /**
- * Called when the activity is first created.
- */
- Thread splashTread;
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_splash_screen);
- StartAnimations();
- }
- private void StartAnimations() {
- Animation anim = AnimationUtils.loadAnimation(this, R.anim.alpha);
- anim.reset();
- LinearLayout l = (LinearLayout) findViewById(R.id.lin_lay);
- l.clearAnimation();
- l.startAnimation(anim);
- anim = AnimationUtils.loadAnimation(this, R.anim.translate);
- anim.reset();
- ImageView iv = (ImageView) findViewById(R.id.splash);
- iv.clearAnimation();
- iv.startAnimation(anim);
- splashTread = new Thread() {
- @Override
- public void run() {
- try {
- int waited = 0;
- // Splash screen pause time
- while (waited < 3500) {
- sleep(100);
- waited += 100;
- }
- Intent intent = new Intent(SplashScreenActivity.this,
- MainActivity.class);
- intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
- startActivity(intent);
- SplashScreenActivity.this.finish();
- } catch (InterruptedException e) {
- // do nothing
- } finally {
- SplashScreenActivity.this.finish();
- }
- }
- };
- splashTread.start();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement