它是安全启动和活动从非UI线程? [英] Is it safe to launch and activity from a non-ui thread?
本文介绍了它是安全启动和活动从非UI线程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我的活动UI线程生成一个单独的线程在一些点。它是安全的新的线程来断火的意图展开新的活动?
Suppose my activity ui-thread spawns a separate thread at some point. Is it safe for that new thread to fire off an Intent for launching a new activity?
感谢
推荐答案
我可能是错的,但我觉得 startActivity()
内部在UI线程中执行。所以,是的,它应该是安全的。
I could be wrong, but I think startActivity()
internally executes in the UI thread. So yes, it should be safe.
如果你想成为100%的把握,调用你的 startActivity()
在活动的 runOnUiThread()
作为一个的Runnable
。
If you wanted to be 100% sure, invoke your startActivity()
in your activity's runOnUiThread()
as a Runnable
.
这篇关于它是安全启动和活动从非UI线程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文