# AccessibilityNodeProviderCompat

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/view/accessibility/AccessibilityNodeProviderCompat.java+class:androidx.core.view.accessibility.AccessibilityNodeProviderCompat) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

*** ** * ** ***


```
public class AccessibilityNodeProviderCompat
```

<br />

*** ** * ** ***

Helper for accessing `https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeProvider.html`.
Consider using a , a utility extension of AccessibilityNodeProvider, to simplify many aspects of providing information to accessibility services and managing accessibility focus.

## Summary

| ### Constants |
|---|---|
| `static final int` | `https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeProviderCompat#HOST_VIEW_ID() = -1` The virtual id for the hosting View. |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeProviderCompat#AccessibilityNodeProviderCompat()()` Creates a new instance. |
| `https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeProviderCompat#AccessibilityNodeProviderCompat(java.lang.Object)(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/Object.html provider)` Creates a new instance wrapping an `https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeProvider.html`. |

| ### Public methods |
|---|---|
| `void` | `https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeProviderCompat#addExtraDataToAccessibilityNodeInfo(int,androidx.core.view.accessibility.AccessibilityNodeInfoCompat,java.lang.String,android.os.Bundle)( int virtualViewId, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat info, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html extraDataKey, @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/os/Bundle.html arguments )` Adds extra data to an `https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat` based on an explicit request for the additional data. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat` | `https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeProviderCompat#createAccessibilityNodeInfo(int)(int virtualViewId)` Returns an `https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat` representing a virtual view, i.e. a descendant of the host View, with the given `virtualViewId` or the host View itself if `virtualViewId` equals to `https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeProviderCompat#HOST_VIEW_ID()`. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat>` | `https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeProviderCompat#findAccessibilityNodeInfosByText(java.lang.String,int)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html text, int virtualViewId)` Finds `https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat`s by text. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat` | `https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeProviderCompat#findFocus(int)(int focus)` Find the virtual view, i.e. a descendant of the host View, that has the specified focus type. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/Object.html` | `https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeProviderCompat#getProvider()()` |
| `boolean` | `https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeProviderCompat#performAction(int,int,android.os.Bundle)(int virtualViewId, int action, @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/os/Bundle.html arguments)` Performs an accessibility action on a virtual view, i.e. a descendant of the host View, with the given `virtualViewId` or the host View itself if `virtualViewId` equals to `https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeProviderCompat#HOST_VIEW_ID()`. |

## Constants

### HOST_VIEW_ID

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final int HOST_VIEW_ID = -1
```

The virtual id for the hosting View.

## Public constructors

### AccessibilityNodeProviderCompat

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public AccessibilityNodeProviderCompat()
```

Creates a new instance.

### AccessibilityNodeProviderCompat

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public AccessibilityNodeProviderCompat(@Nullable Object provider)
```

Creates a new instance wrapping an `https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeProvider.html`.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/Object.html provider` | The provider. |

## Public methods

### addExtraDataToAccessibilityNodeInfo

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/core#1.5.0)

```
public void addExtraDataToAccessibilityNodeInfo(
    int virtualViewId,
    @NonNull AccessibilityNodeInfoCompat info,
    @NonNull String extraDataKey,
    @Nullable Bundle arguments
)
```

Adds extra data to an `https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat` based on an explicit request for the additional data.

This method only needs to be implemented if a virtual view offers to provide additional data.

| Parameters |
|---|---|
| `int virtualViewId` | The virtual view id used to create the node |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat info` | The info to which to add the extra data |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html extraDataKey` | A key specifying the type of extra data to add to the info. The extra data should be added to the `https://developer.android.com/reference/android/os/Bundle.html` returned by the info's `https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat#getExtras()` method. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/os/Bundle.html arguments` | A `https://developer.android.com/reference/android/os/Bundle.html` holding any arguments relevant for this request. |

| See also |
|---|---|
| `https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.html#setAvailableExtraData(java.util.List&lt;java.lang.String&gt;)` |   |

### createAccessibilityNodeInfo

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public @Nullable AccessibilityNodeInfoCompat createAccessibilityNodeInfo(int virtualViewId)
```

Returns an `https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat` representing a virtual view, i.e. a descendant of the host View, with the given `virtualViewId` or the host View itself if `virtualViewId` equals to `https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeProviderCompat#HOST_VIEW_ID()`.

A virtual descendant is an imaginary View that is reported as a part of the view hierarchy for accessibility purposes. This enables custom views that draw complex content to report them selves as a tree of virtual views, thus conveying their logical structure.

The implementer is responsible for obtaining an accessibility node info from the pool of reusable instances and setting the desired properties of the node info before returning it.

| Parameters |
|---|---|
| `int virtualViewId` | A client defined virtual view id. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat` | A populated `https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat` for a virtual descendant or the host View. |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat` |   |

### findAccessibilityNodeInfosByText

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public @Nullable List<AccessibilityNodeInfoCompat> findAccessibilityNodeInfosByText(@NonNull String text, int virtualViewId)
```

Finds `https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat`s by text. The match is case insensitive containment. The search is relative to the virtual view, i.e. a descendant of the host View, with the given `virtualViewId` or the host View itself `virtualViewId` equals to `https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeProviderCompat#HOST_VIEW_ID()`.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html text` | The searched text. |
| `int virtualViewId` | A client defined virtual view id which defined the root of the tree in which to perform the search. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat>` | A list of node info. |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeProviderCompat#createAccessibilityNodeInfo(int)` |   |
| `https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat` |   |

### findFocus

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public @Nullable AccessibilityNodeInfoCompat findFocus(int focus)
```

Find the virtual view, i.e. a descendant of the host View, that has the specified focus type.

| Parameters |
|---|---|
| `int focus` | The focus to find. One of `https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat#FOCUS_INPUT()` or `https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat#FOCUS_ACCESSIBILITY()`. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat` | The node info of the focused view or null. |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat#FOCUS_INPUT()` |   |
| `https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat#FOCUS_ACCESSIBILITY()` |   |

### getProvider

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public @Nullable Object getProvider()
```

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/Object.html` | The wrapped `https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeProvider.html`. |

### performAction

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public boolean performAction(int virtualViewId, int action, @Nullable Bundle arguments)
```

Performs an accessibility action on a virtual view, i.e. a descendant of the host View, with the given `virtualViewId` or the host View itself if `virtualViewId` equals to `https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeProviderCompat#HOST_VIEW_ID()`.

| Parameters |
|---|---|
| `int virtualViewId` | A client defined virtual view id. |
| `int action` | The action to perform. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/os/Bundle.html arguments` | Optional arguments. |

| Returns |
|---|---|
| `boolean` | True if the action was performed. |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeProviderCompat#createAccessibilityNodeInfo(int)` |   |
| `https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat` |   |