Instrumentation.GetUiAutomation(UiAutomationFlags) Method

Definition

Gets the UiAutomation instance with flags set.

[Android.Runtime.Register("getUiAutomation", "(I)Landroid/app/UiAutomation;", "GetGetUiAutomation_IHandler", ApiSince=24)]
public virtual Android.App.UiAutomation? GetUiAutomation (Android.App.UiAutomationFlags flags);
[<Android.Runtime.Register("getUiAutomation", "(I)Landroid/app/UiAutomation;", "GetGetUiAutomation_IHandler", ApiSince=24)>]
abstract member GetUiAutomation : Android.App.UiAutomationFlags -> Android.App.UiAutomation
override this.GetUiAutomation : Android.App.UiAutomationFlags -> Android.App.UiAutomation

Parameters

flags
UiAutomationFlags

The flags to be passed to the UiAutomation, for example UiAutomation#FLAG_DONT_SUPPRESS_ACCESSIBILITY_SERVICES, UiAutomation#FLAG_DONT_USE_ACCESSIBILITY.

Returns

The UI automation instance.

Attributes

Remarks

Gets the UiAutomation instance with flags set.

<strong>Note:</strong> The APIs exposed via the returned UiAutomation work across application boundaries while the APIs exposed by the instrumentation do not. For example, Instrumentation#sendPointerSync(MotionEvent) will not allow you to inject the event in an app different from the instrumentation target, while UiAutomation#injectInputEvent(android.view.InputEvent, boolean) will work regardless of the current application.

A typical test case should be using either the UiAutomation or Instrumentation APIs. Using both APIs at the same time is not a mistake by itself but a client has to be aware of the APIs limitations.

If a UiAutomation exists with different flags, the flags on that instance will be changed, and then it will be returned.

Compatibility mode: This method is infallible for apps targeted for Build.VERSION_CODES#R and earlier versions; for apps targeted for later versions, it will return null if UiAutomation fails to connect. The caller can check the return value and retry on error.

Java documentation for android.app.Instrumentation.getUiAutomation(int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to