Update textView from thread

前端 未结 2 1169
借酒劲吻你
借酒劲吻你 2020-12-06 06:58

In my OnCreate method I have created a thread that listens to incoming message!

In OnCreate() {

//Some code

myThread = new Thread() {

            @Overrid         


        
2条回答
  •  情歌与酒
    2020-12-06 07:12

    Android supports message-passing concurrency using handlers and sendMessage(msg). (It is also possible to use handlers for shared-memory concurrency.) One tip is to call thread.setDaemon(true) if you wish the thread to die when the app dies. The other tip is to have only one handler and use message.what and a switch statement in the message handler to route messages.

    Code and Code

提交回复
热议问题