Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class MyFragment : Fragment() {
- private lateinit var job : Job
- override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
- super.onViewCreated(view, savedInstanceState)
- job = viewLifecycleOwner.lifecycleScope.launch {
- while (true) {
- Log.e("lifecycleScope", "launchWithDelay")
- delay(1000)
- }
- }
- }
- override fun onDestroyView() {
- Log.e("onDestroyView", "job isCancelled : ${job.isCancelled}")
- super.onDestroyView()
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement