91 0

To modify the textview of the main UI, call the append error directly in the child thread. It's found that the handle and message can be solved by using handle and message, reference some online information, solving problems, but here's what the

2 Answers

71 1

A 1. Why not modify UI in UI threads? because android UI components aren't, android uses mode to e & ure that the UI component isn't modified at the same time by different threads. Fyi: activity has runonuithread that makes code execute in UI threads.

A mechanism for 2. Handle and message? simply this is called mechanism. For a detailed point, you need to know that there's a looper class, handler and it share a message queue with the looper, and the looper will call the handleMessage method in the message queue, and calls the method of the handler to handle this message.
And you might wonder why you use the handler, you don't have to contact any looper. looper. Prepare, looper ( ), threadlocal, handler, looper, looper,. Handler looper. android UI UI looper, handler UI, UI., looper. Prepare looper. Loop. Looper. Loop, ,.

I see that my watch is really bad. If you want to understand the point, my suggestion is to look at the source, which is very small.
https://github. com/CyanogenMod/androi..