I'm writing a simple chat application but i don't know how to use my main result handler from another activity. I'm setting resultHandler in main activity like this:
ResultHandler handler = new ResultHandler();
MGey.setUpdatesHandler(handler);
My ResultHandler.java has this code
public class ResultHandler {
@Override
public void onResult(ChatObject object)
{
//receive message object from server
}
}
Now in my other activity (Dialogs.java
) I want to use this handler to get updates.
For example: if my onResult
method receive new message object (ChatObject.NewMessage
) I want to use this object in my Dialogs.java
for new message notification etc.
if (object instanceof ChatObject.NewMessage)
//pass this object to Dialogs activity