Created
December 25, 2019 12:21
-
-
Save wajahatkarim3/7ab61927d0e578b2a440cac4093ef7bd to your computer and use it in GitHub Desktop.
Splash screen with Timer
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
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