Created
December 9, 2022 12:14
-
-
Save imandaliya/1758bc79fd49bf62c22ef20263aa56d2 to your computer and use it in GitHub Desktop.
This file contains 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
// 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