Created
March 10, 2018 20:16
-
-
Save pavelaizen/027ed3827f33edcb2e34fbe9d44a0775 to your computer and use it in GitHub Desktop.
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
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