Here's my android splash screen. I am trying to figure out a better way to write it. It just moves the logo up to the center of the screen. It's my third time creating a splash screen for an android app. I am just trying to figure out the best way to write more optimized code.
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
final public class Splash extends AppCompatActivity {
private final static int timeout = 3000;
final static Handler handler = new Handler();
static ImageView logo;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
logo = findViewById(R.id.companylogo);
Animation animation = AnimationUtils.loadAnimation(Splash.this, R.anim.myanim);
logo.startAnimation(animation);
handler.postDelayed(new Runnable() {
@Override
public void run() {
Intent splashscreen = new Intent(Splash.this, Home.class);
startActivity(splashscreen);
}
}, timeout);
}
}