# InputConnectionCompat

added in [version 25.1.0](https://developer.android.com/topic/libraries/support-library/revisions)   
belongs to Maven artifact com.android.support:support-compat:28.0.0-alpha1  
Summary: [Nested Classes](https://developer.android.com/reference/android/support/v13/view/inputmethod/InputConnectionCompat#nestedclasses) \| [Constants](https://developer.android.com/reference/android/support/v13/view/inputmethod/InputConnectionCompat#constants) \| [Ctors](https://developer.android.com/reference/android/support/v13/view/inputmethod/InputConnectionCompat#pubctors) \| [Methods](https://developer.android.com/reference/android/support/v13/view/inputmethod/InputConnectionCompat#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/support/v13/view/inputmethod/InputConnectionCompat#inhmethods) \| [\[Expand All\]](https://developer.android.com/reference/android/support/v13/view/inputmethod/InputConnectionCompat#)  

# InputConnectionCompat

| This package is part of the Android [support library](https://developer.android.com/topic/libraries/support-library) which is no longer maintained. The support library has been superseded by [AndroidX](https://developer.android.com/jetpack/androidx) which is part of [Jetpack](https://developer.android.com/jetpack). We recommend using the AndroidX libraries in all new projects. You should also consider [migrating](https://developer.android.com/jetpack/androidx/migrate) existing projects to AndroidX. To find the AndroidX class that maps to this deprecated class, see the AndroidX support library [class
| mappings](https://developer.android.com/jetpack/androidx/migrate/class-mappings).


`
public

final

class
InputConnectionCompat
`


`

extends Object


`

`


`

|---|------------------------------------------------------------|
| java.lang.Object                                              ||
| ↳ | android.support.v13.view.inputmethod.InputConnectionCompat |

<br />

*** ** * ** ***

Helper for accessing features in [InputConnection](https://developer.android.com/reference/android/view/inputmethod/InputConnection.html) introduced after API level 13 in a
backwards compatible fashion.

## Summary

|                                                                                                                          ### Nested classes                                                                                                                          ||
|--------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` interface` | [InputConnectionCompat.OnCommitContentListener](https://developer.android.com/reference/android/support/v13/view/inputmethod/InputConnectionCompat.OnCommitContentListener) Listener for commitContent method call, in a backwards compatible fashion. |

|                                                                                                                                                                                                                                                                                        ### Constants                                                                                                                                                                                                                                                                                         ||
|-------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `int` | [INPUT_CONTENT_GRANT_READ_URI_PERMISSION](https://developer.android.com/reference/android/support/v13/view/inputmethod/InputConnectionCompat#INPUT_CONTENT_GRANT_READ_URI_PERMISSION) When this flag is used, the editor will be able to request temporary access permissions to the content URI contained in the [InputContentInfoCompat](https://developer.android.com/reference/android/support/v13/view/inputmethod/InputContentInfoCompat) object, in a similar manner that has been recommended in [Sharing Files](https://developer.android.com/training/secure-file-sharing). |

|                                                                    ### Public constructors                                                                     ||
|-------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[InputConnectionCompat](https://developer.android.com/reference/android/support/v13/view/inputmethod/InputConnectionCompat#InputConnectionCompat())`() ` |

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       ### Public methods                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       ||
|--------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` static boolean`                                                                                                  | ` `[commitContent](https://developer.android.com/reference/android/support/v13/view/inputmethod/InputConnectionCompat#commitContent(android.view.inputmethod.InputConnection, android.view.inputmethod.EditorInfo, android.support.v13.view.inputmethod.InputContentInfoCompat, int, android.os.Bundle))`(`[InputConnection](https://developer.android.com/reference/android/view/inputmethod/InputConnection.html)` inputConnection, `[EditorInfo](https://developer.android.com/reference/android/view/inputmethod/EditorInfo.html)` editorInfo, `[InputContentInfoCompat](https://developer.android.com/reference/android/support/v13/view/inputmethod/InputContentInfoCompat)` inputContentInfo, int flags, `[Bundle](https://developer.android.com/reference/android/os/Bundle.html)` opts) ` Calls commitContent API, in a backwards compatible fashion.                                                                                                                                                                                                                                                                                                                                                                             |
| ` static `[InputConnection](https://developer.android.com/reference/android/view/inputmethod/InputConnection.html) | ` `[createWrapper](https://developer.android.com/reference/android/support/v13/view/inputmethod/InputConnectionCompat#createWrapper(android.view.inputmethod.InputConnection, android.view.inputmethod.EditorInfo, android.support.v13.view.inputmethod.InputConnectionCompat.OnCommitContentListener))`(`[InputConnection](https://developer.android.com/reference/android/view/inputmethod/InputConnection.html)` inputConnection, `[EditorInfo](https://developer.android.com/reference/android/view/inputmethod/EditorInfo.html)` editorInfo, `[InputConnectionCompat.OnCommitContentListener](https://developer.android.com/reference/android/support/v13/view/inputmethod/InputConnectionCompat.OnCommitContentListener)` onCommitContentListener) ` Creates a wrapper [InputConnection](https://developer.android.com/reference/android/view/inputmethod/InputConnection.html) object from an existing [InputConnection](https://developer.android.com/reference/android/view/inputmethod/InputConnection.html) and [InputConnectionCompat.OnCommitContentListener](https://developer.android.com/reference/android/support/v13/view/inputmethod/InputConnectionCompat.OnCommitContentListener) that can be returned to the system. |

| ### Inherited methods |
|-----------------------|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v13/view/inputmethod/InputConnectionCompat#)From class ` java.lang.Object ` |-------------------|-------------------------------| | ` Object`         | ` clone() `                   | | ` boolean`        | ` equals(Object arg0) `       | | ` void`           | ` finalize() `                | | ` final Class<?>` | ` getClass() `                | | ` int`            | ` hashCode() `                | | ` final void`     | ` notify() `                  | | ` final void`     | ` notifyAll() `               | | ` String`         | ` toString() `                | | ` final void`     | ` wait(long arg0, int arg1) ` | | ` final void`     | ` wait(long arg0) `           | | ` final void`     | ` wait() `                    | ||

## Constants

### INPUT_CONTENT_GRANT_READ_URI_PERMISSION

added in [version 25.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
int INPUT_CONTENT_GRANT_READ_URI_PERMISSION
```

When this flag is used, the editor will be able to request temporary access permissions to
the content URI contained in the [InputContentInfoCompat](https://developer.android.com/reference/android/support/v13/view/inputmethod/InputContentInfoCompat) object, in a similar manner
that has been recommended in
[Sharing Files](https://developer.android.com/training/secure-file-sharing).

Make sure that the content provider owning the Uri sets the
[grantUriPermissions](https://developer.android.com/reference/android/R.attr#grantUriPermissions) attribute in its manifest or
included the `&lt;grant-uri-permissions&gt;` tag.

Supported only on API \>= 25.

On API \<= 24 devices, IME developers need to ensure that the content URI is accessible
only from the target application, for example, by generating a URL with a unique name that
others cannot guess. IME developers can also rely on the following information of the target
application to do additional access checks in their [ContentProvider](https://developer.android.com/reference/android/content/ContentProvider.html).

- On API \>= 23 [packageName](https://developer.android.com/reference/android/view/inputmethod/EditorInfo.html#packageName) is guaranteed to not be spoofed, which can later be compared with [getCallingPackage()](https://developer.android.com/reference/android/content/ContentProvider.html#getCallingPackage()) in the [ContentProvider](https://developer.android.com/reference/android/content/ContentProvider.html).
- [getUid()](https://developer.android.com/reference/android/view/inputmethod/InputBinding.html#getUid()) is guaranteed to not be spoofed, which can later be compared with [getCallingUid()](https://developer.android.com/reference/android/os/Binder.html#getCallingUid()) in the [ContentProvider](https://developer.android.com/reference/android/content/ContentProvider.html).

<br />

<br />

Constant Value:

1
(0x00000001)


## Public constructors

### InputConnectionCompat

added in [version 25.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
InputConnectionCompat ()
```

<br />

<br />

## Public methods

### commitContent

added in [version 25.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
boolean commitContent (InputConnection inputConnection, 
                EditorInfo editorInfo, 
                InputContentInfoCompat inputContentInfo, 
                int flags, 
                Bundle opts)
```

Calls commitContent API, in a backwards compatible fashion.

<br />

|                                                                                                           Parameters                                                                                                           ||
|--------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `inputConnection`  | `InputConnection`: [InputConnection](https://developer.android.com/reference/android/view/inputmethod/InputConnection.html) with which commitContent API will be called <br />                             |
| `editorInfo`       | `EditorInfo`: [EditorInfo](https://developer.android.com/reference/android/view/inputmethod/EditorInfo.html) associated with the given `inputConnection` <br />                                            |
| `inputContentInfo` | `InputContentInfoCompat`: content information to be passed to the editor <br />                                                                                                                            |
| `flags`            | `int`: `0` or [INPUT_CONTENT_GRANT_READ_URI_PERMISSION](https://developer.android.com/reference/android/support/v13/view/inputmethod/InputConnectionCompat#INPUT_CONTENT_GRANT_READ_URI_PERMISSION) <br /> |
| `opts`             | `Bundle`: optional bundle data. This can be `null` <br />                                                                                                                                                  |

|                                                                          Returns                                                                          ||
|-----------|------------------------------------------------------------------------------------------------------------------------------------------------|
| `boolean` | `true` if this request is accepted by the application, no matter if the request is already handled or still being handled in background <br /> |

### createWrapper

added in [version 25.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
InputConnection createWrapper (InputConnection inputConnection, 
                EditorInfo editorInfo, 
                InputConnectionCompat.OnCommitContentListener onCommitContentListener)
```

Creates a wrapper [InputConnection](https://developer.android.com/reference/android/view/inputmethod/InputConnection.html) object from an existing [InputConnection](https://developer.android.com/reference/android/view/inputmethod/InputConnection.html)
and [InputConnectionCompat.OnCommitContentListener](https://developer.android.com/reference/android/support/v13/view/inputmethod/InputConnectionCompat.OnCommitContentListener) that can be returned to the system.

By returning the wrapper object to the IME, the editor can be notified by
[onCommitContent(InputContentInfoCompat, int, Bundle)](https://developer.android.com/reference/android/support/v13/view/inputmethod/InputConnectionCompat.OnCommitContentListener#onCommitContent(android.support.v13.view.inputmethod.InputContentInfoCompat, int, android.os.Bundle))
when the IME calls
[commitContent(InputConnection, EditorInfo, InputContentInfoCompat, int, Bundle)](https://developer.android.com/reference/android/support/v13/view/inputmethod/InputConnectionCompat#commitContent(android.view.inputmethod.InputConnection, android.view.inputmethod.EditorInfo, android.support.v13.view.inputmethod.InputContentInfoCompat, int, android.os.Bundle)) and the corresponding Framework API that is available
on API \>= 25.

<br />

<br />

|                                                                                         Parameters                                                                                         ||
|---------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `inputConnection`         | `InputConnection`: [InputConnection](https://developer.android.com/reference/android/view/inputmethod/InputConnection.html) to be wrapped <br />                |
| `editorInfo`              | `EditorInfo`: [EditorInfo](https://developer.android.com/reference/android/view/inputmethod/EditorInfo.html) associated with the given `inputConnection` <br /> |
| `onCommitContentListener` | `InputConnectionCompat.OnCommitContentListener`: the listener that the wrapper object will call <br />                                                          |

|                                                                                                                                  Returns                                                                                                                                   ||
|----------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [InputConnection](https://developer.android.com/reference/android/view/inputmethod/InputConnection.html) | a wrapper [InputConnection](https://developer.android.com/reference/android/view/inputmethod/InputConnection.html) object that can be returned to the IME <br /> |

|                                                  Throws                                                  ||
|----------------------------|------------------------------------------------------------------------------|
| `IllegalArgumentException` | when `inputConnection`, `editorInfo`, or `onCommitContentListener` is `null` |

-

  ## Interfaces

  - [InputConnectionCompat.OnCommitContentListener](https://developer.android.com/reference/android/support/v13/view/inputmethod/InputConnectionCompat.OnCommitContentListener)
-

  ## Classes

  - [EditorInfoCompat](https://developer.android.com/reference/android/support/v13/view/inputmethod/EditorInfoCompat)
  - [InputConnectionCompat](https://developer.android.com/reference/android/support/v13/view/inputmethod/InputConnectionCompat)
  - [InputContentInfoCompat](https://developer.android.com/reference/android/support/v13/view/inputmethod/InputContentInfoCompat)