This week's book giveaway is in the OCAJP forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.
The moose likes Android and the fly likes What does ZERO in Handler.sendEmptyMessage(0); mean? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA Java SE 8 Programmer I Study Guide 1Z0-808 this week in the OCAJP forum!
JavaRanch » Java Forums » Mobile » Android
Bookmark "What does ZERO in Handler.sendEmptyMessage(0); mean?" Watch "What does ZERO in Handler.sendEmptyMessage(0); mean?" New topic
Author

What does ZERO in Handler.sendEmptyMessage(0); mean?

Saurabh Pillai
Ranch Hand

Joined: Sep 12, 2008
Posts: 510
Why do we pass 0? Can we pass any integer?

From API docs,

public final boolean sendEmptyMessage (int what)
Since: API Level 1

Sends a Message containing only the what value.
Returns

Returns true if the message was successfully placed in to the message queue. Returns false on failure, usually because the looper processing the message queue is exiting.

Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2409
What happened when you tried? What would you expect to happen based on the description "Sends a Message containing only the 'what' value"?
Saurabh Pillai
Ranch Hand

Joined: Sep 12, 2008
Posts: 510
What would you expect to happen based on the description "Sends a Message containing only the 'what' value"?

I am reading 'Android in Action' book, and below is the code excerpt. Though we are passing 0, but we are not utilizing it anywhere (atleast not that I am aware of). and that is how the question arose.



Saurabh Pillai
Ranch Hand

Joined: Sep 12, 2008
Posts: 510
Guys, can somebody help me here?
 
wood burning stoves
 
subject: What does ZERO in Handler.sendEmptyMessage(0); mean?