DJ180
DJ180

Reputation: 19854

Possible to check what callbacks have been added to Android Handler?

In my Android application, I've a number of custom Task objects (implementations of Runnable) that I post to a Handler on a non UI thread. Depending on some logic elsewhere in my application, I'd like to see what is on the queue at a specific time. From looking at the Handler API, I see ways to query what messages are on the handler but not what callbacks? Is there any way to perform this? It seems strange that you can remove callbacks but not query using the same parameter....

Thanks

Upvotes: 3

Views: 1505

Answers (1)

Daniel Fekete
Daniel Fekete

Reputation: 5028

Browsing through the Handler, MessageQueue, and Message source code, I dont think it is possible.

Messages are added in MessageQueue.enqueueMessage(), and removed in MessageQueue.next() , it is not possible to query what is in the queue.

Runnables added in Handler.postXXX(Runnable...) are wrapped into a Message object too.

Upvotes: 5

Related Questions