Launching Splash Screen in Android Different Ways

Bhanu Pro
1 min readMar 19, 2021

--

Photo by Bill Jelen on Unsplash

Nowadays, Every android app is using a splash screen in one way or another way. From Popular android apps like Whatsapp, Facebook to small apps.

Today I am going to write code for launching splash in different ways from the old Handler way to new coroutines.

Using Threads:

new Thread(new Runnable() {
public void run() {
try {
Thread.sleep(1700);
} catch (InterruptedException e) {
e.printStackTrace();
}
launchDashboard();
}
}).start();

Using Handler:

new Handler().postDelayed(new Runnable(){
@Override
public void run() {
launchDashboard
}
}, 1700);

Using Timer:

new Timer().schedule(new TimerTask() {          
@Override
public void run() {
launchDashboard();
}
}, 1700);

Using CounDownTimer:

new CountDownTimer(30000, 1000) {

public void onTick(long millisUntilFinished) {}

public void onFinish() {
launchDashboard();
}

}.start();

Using LifeCycleScope:

lifecycleScope.launchWhenStarted {
delay(1700)
launchDashboard()
}

Using CoroutineScope:

CoroutineScope(Job()).launch { 
delay(1700)
launchDashboard()
}

But here you have to manage the scope of the coroutine, otherwise, it may leak memory.

Comment down your favourite and best one in below

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Bhanu Pro
Bhanu Pro

Responses (2)

Write a response