#新人报道#
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main2)
// 方式一
val job = lifecycleScope.launchWhenCreated {
suspendCoroutine<Unit> {
thread {
Thread.sleep(3000)
it.resume(Unit)
}
}
throw IllegalStateException("")
}
//方式二
lifecycleScope.launch {
suspendCoroutine<Unit> {
thread {
Thread.sleep(3000)
it.resume(Unit)
}
}
throw IllegalStateException("")
}
}
进入activity直接返回上一个页面为什么方式二会导致crash,第一种方式不会,Android小白指教
展开
评论