I understand I need to put the code for long processing time to my own thread, not the UI thread. My question is why in my own thread, android does not let me update the UI, e.g. update the text of my TextView in UI?
Thank you.
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.
As a design tradeoff, the Android UI toolkit is not thread-safe. So you cannot update the UI from any thread other than your UI thread. The platform provides a number of ways (such as
runOnUIThread) to make it painless to dispatch tasks to the UI thread so that it can update the UI.