Share via


AccessibilityService.FindFocus(NodeFocus) Method

Definition

Find the view that has the specified focus type.

[Android.Runtime.Register("findFocus", "(I)Landroid/view/accessibility/AccessibilityNodeInfo;", "GetFindFocus_IHandler")]
public virtual Android.Views.Accessibility.AccessibilityNodeInfo? FindFocus (Android.Views.Accessibility.NodeFocus focus);
[<Android.Runtime.Register("findFocus", "(I)Landroid/view/accessibility/AccessibilityNodeInfo;", "GetFindFocus_IHandler")>]
abstract member FindFocus : Android.Views.Accessibility.NodeFocus -> Android.Views.Accessibility.AccessibilityNodeInfo
override this.FindFocus : Android.Views.Accessibility.NodeFocus -> Android.Views.Accessibility.AccessibilityNodeInfo

Parameters

focus
NodeFocus

The focus to find. One of AccessibilityNodeInfo#FOCUS_INPUT or AccessibilityNodeInfo#FOCUS_ACCESSIBILITY.

Returns

The node info of the focused view or null.

Attributes

Remarks

Find the view that has the specified focus type. The search is performed across all windows.

<strong>Note:</strong> In order to access the windows your service has to declare the capability to retrieve window content by setting the android.R.styleable#AccessibilityService_canRetrieveWindowContent property in its meta-data. For details refer to #SERVICE_META_DATA. Also the service has to opt-in to retrieve the interactive windows by setting the AccessibilityServiceInfo#FLAG_RETRIEVE_INTERACTIVE_WINDOWS flag. Otherwise, the search will be performed only in the active window.

<strong>Note:</strong> If the view with AccessibilityNodeInfo#FOCUS_INPUT is on an embedded view hierarchy which is embedded in a android.view.SurfaceView via android.view.SurfaceView#setChildSurfacePackage, there is a limitation that this API won't be able to find the node for the view. It's because views don't know about the embedded hierarchies. Instead, you could traverse all the nodes to find the focus.

Java documentation for android.accessibilityservice.AccessibilityService.findFocus(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

See also