Skip to content

Instantly share code, notes, and snippets.

@imandaliya
Created December 9, 2022 12:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imandaliya/1758bc79fd49bf62c22ef20263aa56d2 to your computer and use it in GitHub Desktop.
Save imandaliya/1758bc79fd49bf62c22ef20263aa56d2 to your computer and use it in GitHub Desktop.
// Reference : https://blog.kiprosh.com/how-to-avoid-double-splash-screens-in-android-12/
class SplashActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_splash)
val content = findViewById<View>(android.R.id.content)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
content.viewTreeObserver.addOnDrawListener { false }
}
callNextScreen()
}
private fun callNextScreen() {
Handler().postDelayed({
val intent = Intent(this, MainActivity::class.java)
startActivity(intent)
finish()
}, 2000)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment