Last active
July 19, 2018 13:36
-
-
Save dharmakshetri/2471b522b929721363c81f9da386bacd to your computer and use it in GitHub Desktop.
splash screen in kotlin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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