![]() The sendMessage versions allow you to enqueue a Message object containing a bundle of data that will be processed by the Handler’s handleMessage(Message) method (requiring that you implement a subclass of Handler).ĭifference between post() and sendMessage()Ĭonventionally you use post() when you want to execute some code on the UI Thread without having to know anything about your Handler object. The post versions allow you to enqueue Runnable objects to be called by the message queue when they are received. Scheduling messages is accomplished with the post(Runnable), postAtTime(Runnable, long), postDelayed(Runnable, long), sendEmptyMessage(int), sendMessage(Message), sendMessageAtTime(Message, long), and sendMessageDelayed(Message, long) methods. In other words enqueue an action to perform on different thread. ![]() ![]() (2) To enqueue an action to be performed on a different thread than your own. In other words perform action on same thread in future. (1) To schedule messages and runnables to be executed as some point in the future. ![]() When you create a new Handler, it is bound to the thread / message queue of the thread that is creating it - from that point on, it will deliver messages and runnables to that message queue and execute them as they come out of the message queue. Each Handler instance is associated with a single thread and that thread’s message queue. ![]() A Handler allows you to send and process Message and Runnable objects associated with a thread’s MessageQueue. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |