Skip to content

Instantly share code, notes, and snippets.

@wajahatkarim3
Created December 25, 2019 12:21
Show Gist options
  • Save wajahatkarim3/7ab61927d0e578b2a440cac4093ef7bd to your computer and use it in GitHub Desktop.
Save wajahatkarim3/7ab61927d0e578b2a440cac4093ef7bd to your computer and use it in GitHub Desktop.
Splash screen with Timer
package com.wajahatkarim.splashscreen
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import kotlinx.coroutines.cancel
import java.util.*
import kotlin.concurrent.schedule
class TimerSplashActivity : AppCompatActivity() {
var timer = Timer()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_timer_splash)
timer.schedule(3000) {
var intent = Intent(this@TimerSplashActivity, HomeActivity::class.java)
startActivity(intent)
finish()
}
}
override fun onPause() {
timer.cancel()
super.onPause()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment