TamiL
TamiL

Reputation: 2896

How to display messages from handler?

This is my code:

public void handleMessage(Message msg) {
    if (msg != null){
        Log.i("Working1", msg.toString());

    }
}

Log.i("Working1", msg.toString()); This Logs the objects in the messages

How can I display the all content of the object or message..?? Give me any solutions..

Upvotes: 1

Views: 272

Answers (1)

Shashank Kadne
Shashank Kadne

Reputation: 8101

Basically you will store your object in the obj field of your Message.

Message m = new Message();
m.obj = yourObject;
handler.sendMessage(m);

Inside the handleMessage(Message msg) function you can typecast the Message to your intended object;

public void handleMessage(Message msg) {
        if (msg != null){

         YourClass object = (YourClass)msg.obj;
         //Process object;
        }
    }

Upvotes: 2

Related Questions