Skip to content

Instantly share code, notes, and snippets.

@dharmakshetri
Last active July 19, 2018 13:36
Show Gist options
  • Select an option

  • Save dharmakshetri/2471b522b929721363c81f9da386bacd to your computer and use it in GitHub Desktop.

Select an option

Save dharmakshetri/2471b522b929721363c81f9da386bacd to your computer and use it in GitHub Desktop.
splash screen in kotlin
class SpashScreen : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_splash)
val background = object : Thread() {
override fun run() {
try {
// Thread will sleep for 5 seconds
Thread.sleep((5 * 1000).toLong())
// After 5 seconds redirect to another intent
val i = Intent(baseContext, MainActivity::class.java)
startActivity(i)
//Remove activity
finish()
} catch (e: Exception) {
e.printStackTrace()
}
}
}
// start thread
background.start()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment