Android Dev Summit, October 23-24: two days of technical content, directly from the Android team. Sign-up for livestream updates.

MessageCompat

public final class MessageCompat
extends Object

java.lang.Object
   ↳ androidx.core.os.MessageCompat


Helper for accessing features in Message.

Summary

Public methods

static boolean isAsynchronous(Message message)

Returns true if the message is asynchronous, meaning that it is not subject to Looper synchronization barriers.

static void setAsynchronous(Message message, boolean async)

Sets whether the message is asynchronous, meaning that it is not subject to Looper synchronization barriers.

Inherited methods

Public methods

isAsynchronous

public static boolean isAsynchronous (Message message)

Returns true if the message is asynchronous, meaning that it is not subject to Looper synchronization barriers.

Parameters
message Message

Returns
boolean True if the message is asynchronous. Always false prior to API 16.

setAsynchronous

public static void setAsynchronous (Message message, 
                boolean async)

Sets whether the message is asynchronous, meaning that it is not subject to Looper synchronization barriers.

Certain operations, such as view invalidation, may introduce synchronization barriers into the Looper's message queue to prevent subsequent messages from being delivered until some condition is met. In the case of view invalidation, messages which are posted after a call to View.invalidate() are suspended by means of a synchronization barrier until the next frame is ready to be drawn. The synchronization barrier ensures that the invalidation request is completely handled before resuming.

Asynchronous messages are exempt from synchronization barriers. They typically represent interrupts, input events, and other signals that must be handled independently even while other work has been suspended.

Note that asynchronous messages may be delivered out of order with respect to synchronous messages although they are always delivered in order among themselves. If the relative order of these messages matters then they probably should not be asynchronous in the first place. Use with caution.

This API has no effect prior to API 16.

Parameters
message Message

async boolean: True if the message is asynchronous.