I’m implementing IPC via Handlers in an Android application.
In the official documentation (here http://developer.android.com/reference/android/app/Service.html) there’s an example:
class IncomingHandler extends Handler {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case MSG_REGISTER_CLIENT:
mClients.add(msg.replyTo);
break;
case MSG_UNREGISTER_CLIENT:
mClients.remove(msg.replyTo);
break;
case MSG_SET_VALUE:
mValue = msg.arg1;
for (int i=mClients.size()-1; i>=0; i--) {
try {
mClients.get(i).send(Message.obtain(null,
MSG_SET_VALUE, mValue, 0));
} catch (RemoteException e) {
// The client is dead. Remove it from the list;
// we are going through the list from back to front
// so this is safe to do inside the loop.
mClients.remove(i);
}
}
break;
default:
super.handleMessage(msg);
}
}
}
My question is simple: what does this line do?:
super.handleMessage(msg);
Am I obliged to call that method?
EDIT:
I know that this will call the parent’s implementation of that method. But what’s in that method? Is there something special that have to be done prior the release of the message?
Thanks in advance
A quick glance at the source code shows that the super class implementation of this method does nothing. I would call it nonetheless because a future version of Android might behave differently.