This means what . what is basically an integer that allows the recipient to identify received messages.
Your handleMessage function is as follows
public void handleMessage (Message msg)
a Message object is passed to you, and you can check the public what field to find out what the message is. ( msg.what )
Eg.
you send two types of messages: what value is 1 for success and 0 for failure
so your handleMessage function will look something like this.
public void handleMessage (Message msg) { switch (msg.what) { case 1:
Now you can have sendEmptyMessage(0) for success and sendEmptyMessage(1) for failure.
Remember that you do not need to send an empty message, you can send a Message object with a lot of data connected to it.
for example, to send a message with some success text you can do
Message.obtain(mHandler, 0, "Success text")
and likewise for failure
Now, according to what zero means, it just sends an empty message, and 0 can be replaced with any value. The idea is that you have only one type of message, and the handler understands this. Therefore, there is no need to check which message he received, just need to receive a message. So sendEmptyMessage(AnyInteger) will work fine. 0 by agreement only
source share