Skip to content

Instantly share code, notes, and snippets.

@pavelaizen
Created March 10, 2018 20:16
Show Gist options
  • Save pavelaizen/027ed3827f33edcb2e34fbe9d44a0775 to your computer and use it in GitHub Desktop.
Save pavelaizen/027ed3827f33edcb2e34fbe9d44a0775 to your computer and use it in GitHub Desktop.
import android.app.Activity
import android.os.Bundle
import android.widget.Toast
import kotlinx.coroutines.experimental.android.UI
import kotlinx.coroutines.experimental.delay
import kotlinx.coroutines.experimental.launch
import java.util.concurrent.TimeUnit
/**
* Example using Kotlin Coroutines:
* https://kotlinlang.org/docs/tutorials/coroutines-basic-jvm.html
*/
class SampleActivity: Activity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
launch (UI){
delay(5, TimeUnit.SECONDS)
Toast.makeText(this@SampleActivity, "Hello", Toast.LENGTH_SHORT).show()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment