What is the proper way to launch a coroutine from a click event that is defined in a fragment? From my understanding, GlobalScope.launch
is used if you want to launch a coroutine that is supposed to remain in memory for the entire lifecycle of the app. But since a fragment usually has a shorter lifecycle than the app, GlobalScope.launch
probably isn't the proper way. I assume that if I used GlobalScope.launch
, it might keep the fragment from being garbage collected?
我真的只需要从点击事件处理程序启动协同程序,这意味着没有父函数可以调用.