Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Saurabh Pillai
Ranch Hand
Posts: 524
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 2895
46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 524
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 524
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys, can somebody help me here?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic