tags:

views:

34

answers:

2

Is there a way to distinguish between types of messages sent to an Android Handler? For example, I have 2 background threads and would like the handler to recognize which thread a message came from.

+1  A: 

I have never used messages in Android so far, but this suggests that you can add custom values to a message (which would make sense anyway ;) ), so why don't you just let the thread write his id or whatever identifies him into the message before sending it?

And of course check for the id in the Handler.

slup
+1  A: 

the public field 'what' ("User-defined message code so that the recipient can identify what this message is about.") is used for that

Schildmeijer