android.view
public
final
class
android.view.UIThreadUtilities
In Android, Views must be manipulated only from the UI thread. This
class offers various utility methods to abide by this contract.
Because different view hierarchys can run in different threads, the UI thread
is unique to a specific view hierarchy only. For this reason, the methods
exposed in this class must be supplied with a View whose UI thread will be
used.
Summary
Public Constructors
Public Methods
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait
Details
Public Constructors
public
UIThreadUtilities()
Public Methods
public
static
boolean
isUIThread(View view)
Indicates whether the code is currently executing in the UI thread of a
specified view.
Parameters
| view
| the view whose UI thread must be checked, must be attached to a window |
Returns
- true if this method executes in the supplied view's UI thread
public
static
void
runOnUIThread(Dialog dialog, Runnable action)
Runs the specified action on the UI thread. If the current thread is the UI
thread, then the action is executed immediately. If the current thread is
not the UI thread, the action is posted to the event queue of the UI thread.
Parameters
| dialog
| the dialog whose UI thread must be used |
| action
| the action to run on the UI thread |
public
static
void
runOnUIThread(View view, Runnable action)
Runs the specified action on the UI thread. If the current thread is the UI
thread, then the action is executed immediately. If the current thread is
not the UI thread, the action is posted to the event queue of the UI thread.
Parameters
| view
| the view whose UI thread must be used, must be attached to a window |
| action
| the action to run on the UI thread |
public
static
void
runOnUIThread(Activity activity, Runnable action)
Runs the specified action on the UI thread. If the current thread is the UI
thread, then the action is executed immediately. If the current thread is
not the UI thread, the action is posted to the event queue of the UI thread.
Parameters
| activity
| the activity whose UI thread must be used |
| action
| the action to run on the UI thread |