I ma developing an app, which at the moment when it is loading from the onCreate point, I just have a black screen (until the app gets its footing). Looking at other apps they have a company logo or cool image that pops up for a few seconds, can someone tell me how to do this please?
And if you can set it to display for a minimal time?
Create a new activity that displays the image for a few seconds and redirects to your main activity:
public class SplashActivity extends Activity
{
private static final long DELAY = 3000;
private boolean scheduled = false;
private Timer splashTimer;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
splashTimer = new Timer();
splashTimer.schedule(new TimerTask()
{
@Override
public void run()
{
SplashActivity.this.finish();
startActivity(new Intent(SplashActivity.this, MainActivity.class));
}
}, DELAY);
scheduled = true;
}
@Override
protected void onDestroy()
{
super.onDestroy();
if (scheduled)
splashTimer.cancel();
splashTimer.purge();
}
}
Set your image as the background for this activity. Hope that helps. Good luck!
This start up image also known as 'splash screen'. Here you can find how to make splash screen.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With