开发者

Sending messages of different types to Android Handler

开发者 https://www.devze.com 2023-01-06 13:06 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消