O'Reilly logo

Android Programming: The Big Nerd Ranch Guide by Brian Hardy, Bill Phillips

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Messages and Message Handlers

Before you create a message, you need to understand what a Message is, and the relationship it has with its Handler, or message handler.

Message anatomy

Let’s start by looking closely at messages. The messages that a Flash might put in an inbox (its own inbox or that of another Flash) are not supportive notes, like "You run very fast, Flash." They are tasks that need to be handled.

A message is an instance of Message and contains several fields. Three are relevant to your implementation:

what

a user-defined int that describes the message

obj

a user-specified object to be sent with the message

target

the Handler that will handle the message

The target of a Message is an instance of Handler. You can think of the name ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required