What’s the difference between Activity.runOnUiThread and View.post, could someone, please, explain?
What’s the difference between Activity.runOnUiThread and View.post , could someone, please, explain?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There is no real difference, except that the
View.postis helpful when you don’t have a direct access to the activity.In both cases, if not on UI thread,
Handler#post(Runnable)will be called behind the scenes.As CommonsWare mentioned in the comment, there is a difference between the two – when called on Ui thread,
Activity#runOnUiThreadwill call therunmethod directly, whileView#postwill post therunnableon the queue (e.g. call theHandler#post)The important point IMO is that both have the same goal, and for whoever use it, there should be no difference (and the implementation may change in the future).