In my app I want to display a splash screen and after 4 seconds go to HomeActivity. However, I would like to pause the execution by touching imageview imageSplash and resume when releasing. How to do this?
GlobalScope.launch(context = Dispatchers.Main) {
imageSplash.setOnTouchListener { view, motionEvent ->
when(motionEvent.action){
MotionEvent.ACTION_DOWN ->{
true
}
MotionEvent.ACTION_UP->{
true
}
else ->{
false
}
}
}
delay(4000)
val intent = Intent(this@SplashActivity, HomeActivity::class.java)
startActivity(intent)
finish()
}