- Create New Project With EmptyActivity
- Create New Folder in "res" Name it "raw"
- paste your video in "raw" folder
Step 3 :
- Add following code to MainActivity.kt OR your splash screen activity ( for hide status bar)
requestWindowFeature(Window.FEATURE_NO_TITLE)
window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN)
And for hide titlebar , Change AppCompatActivity into Activity
window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN)
And for hide titlebar , Change AppCompatActivity into Activity
- code Add following code in your MainActivity.kt OR your splash screen kotlin activity :
try {
val videoHolder = VideoView(this)
setContentView(videoHolder)
val video = Uri.parse("android.resource://" + packageName + "/" + R.raw.splash)
videoHolder.setVideoURI(video)
videoHolder.setOnCompletionListener { jump() }
videoHolder.start()
} catch (ex: Exception) {
jump()
}
}
override fun onTouchEvent(event: MotionEvent): Boolean {
jump()
return true}
private fun jump() {
if (isFinishing)
return
val intent = Intent(this, Main2Activity::class.java)
startActivity(intent)
finish()
Step 4 :
- Create new activity for your home screen, give name "Main2Activity"
- Run Your App