Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
256 views
in Technique[技术] by (71.8m points)

android - Is it safe to launch an activity from a non-ui thread?

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?

Thanks

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I could be wrong, but I think startActivity() internally executes in the UI thread. So yes, it should be safe.

If you wanted to be 100% sure, invoke your startActivity() in your activity's runOnUiThread() as a Runnable.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...