Sending messages of different types to Android Handler
Is there a way to distinguish between types of messages sent to an Android Handler? For example, I have 2 background开发者_StackOverflow threads and would like the handler to recognize which thread a message came from.
the public field 'what' ("User-defined message code so that the recipient can identify what this message is about.") is used for that
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.
精彩评论