Where can I find pending message on the message queue in android?

痞子三分冷 提交于 2019-12-10 14:25:28

问题


Is there a way to find out the message queue size and what item is in each message? Is it Looper.getMainLoop or something?


回答1:


Hope it's not too late for an answer. You can access the current thread's message queue calling Looper.myQueue() on it. However, the MessageQueue class has no methods to find out its size or what item is in each message. For that purpose, you could try the Handler class. A handler manages a looper, which has a queue, and that handler has methods like hasMessages, obtainMessage, removeMessages, and so on. I think that is your best shot.



来源:https://stackoverflow.com/questions/9478111/where-can-i-find-pending-message-on-the-message-queue-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!