Skip to content

Instantly share code, notes, and snippets.

@vitoksmile
Created March 3, 2025 16:09
Show Gist options
  • Save vitoksmile/9c584937a507bc5c0e617c3ffa9b08c5 to your computer and use it in GitHub Desktop.
Save vitoksmile/9c584937a507bc5c0e617c3ffa9b08c5 to your computer and use it in GitHub Desktop.
Mastering delays in Android
class TestFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
viewLifecycleOwner.lifecycleScope.launch {
repeatOnLifecycle(Lifecycle.State.RESUMED) {
delay(1.seconds)
Toast.makeText(requireContext(), "Hello, Medium", Toast.LENGTH_LONG).show()
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment