java.lang.Object | |
↳ | android.os.MessageQueue |
Low-level class holding the list of messages to be dispatched by a
Looper
. Messages are not added directly to a MessageQueue,
but rather through MessageQueue.IdleHandler
objects associated with the Looper.
You can retrieve the MessageQueue for the current thread with
Looper.myQueue()
.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
MessageQueue.IdleHandler | Callback interface for discovering when a thread is going to block waiting for more messages. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Add a new
MessageQueue.IdleHandler to this message queue. | |||||||||||
Remove an
MessageQueue.IdleHandler from the queue that was previously added
with addIdleHandler(MessageQueue.IdleHandler) . |
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Called before the object's memory is reclaimed by the VM.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Add a new MessageQueue.IdleHandler
to this message queue. This may be
removed automatically for you by returning false from
IdleHandler.queueIdle()
when it is
invoked, or explicitly removing it with removeIdleHandler(MessageQueue.IdleHandler)
.
This method is safe to call from any thread.
handler | The IdleHandler to be added. |
---|
Remove an MessageQueue.IdleHandler
from the queue that was previously added
with addIdleHandler(MessageQueue.IdleHandler)
. If the given object is not currently
in the idle list, nothing is done.
handler | The IdleHandler to be removed. |
---|
Called before the object's memory is reclaimed by the VM. This can only happen once the garbage collector has detected that the object is no longer reachable by any thread of the running application.
The method can be used to free system resources or perform other cleanup
before the object is garbage collected. The default implementation of the
method is empty, which is also expected by the VM, but subclasses can
override finalize()
as required. Uncaught exceptions which are
thrown during the execution of this method cause it to terminate
immediately but are otherwise ignored.
Note that the VM does guarantee that finalize()
is called at most
once for any object, but it doesn't guarantee when (if at all) finalize()
will be called. For example, object B's finalize()
can delay the execution of object A's finalize()
method and
therefore it can delay the reclamation of A's memory. To be safe, use a
ReferenceQueue
, because it provides more control
over the way the VM deals with references during garbage collection.
Throwable |
---|