Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Ctors](https://developer.android.com/reference/android/view/inputmethod/TextSnapshot#pubctors) \| [Methods](https://developer.android.com/reference/android/view/inputmethod/TextSnapshot#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/view/inputmethod/TextSnapshot#inhmethods)

# TextSnapshot

*** ** * ** ***


`
public

final

class
TextSnapshot
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.view.inputmethod.TextSnapshot |

<br />

*** ** * ** ***

An immutable data snapshot of text editing state.

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/view/inputmethod/TextSnapshot#TextSnapshot(android.view.inputmethod.SurroundingText,%20int,%20int,%20int)(https://developer.android.com/reference/android/view/inputmethod/SurroundingText surroundingText, int compositionStart, int compositionEnd, int cursorCapsMode) ` Creates a new instance of `https://developer.android.com/reference/android/view/inputmethod/TextSnapshot` |

| ### Public methods ||
|---|---|
| ` int` | ` https://developer.android.com/reference/android/view/inputmethod/TextSnapshot#getCompositionEnd()() ` |
| ` int` | ` https://developer.android.com/reference/android/view/inputmethod/TextSnapshot#getCompositionStart()() ` |
| ` int` | ` https://developer.android.com/reference/android/view/inputmethod/TextSnapshot#getCursorCapsMode()() ` The capitalization mode of the first character being edited in the text. |
| ` int` | ` https://developer.android.com/reference/android/view/inputmethod/TextSnapshot#getSelectionEnd()() ` |
| ` int` | ` https://developer.android.com/reference/android/view/inputmethod/TextSnapshot#getSelectionStart()() ` |
| ` https://developer.android.com/reference/android/view/inputmethod/SurroundingText` | ` https://developer.android.com/reference/android/view/inputmethod/TextSnapshot#getSurroundingText()() ` |

| ### Inherited methods |
|---|---|
| From class ` https://developer.android.com/reference/java/lang/Object ` |---|---| | ` https://developer.android.com/reference/java/lang/Object` | ` https://developer.android.com/reference/java/lang/Object#clone()() ` Creates and returns a copy of this object. | | ` boolean` | ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Indicates whether some other object is "equal to" this one. | | ` void` | ` https://developer.android.com/reference/java/lang/Object#finalize()() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. | | ` final https://developer.android.com/reference/java/lang/Class<?>` | ` https://developer.android.com/reference/java/lang/Object#getClass()() ` Returns the runtime class of this `Object`. | | ` int` | ` https://developer.android.com/reference/java/lang/Object#hashCode()() ` Returns a hash code value for the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notify()() ` Wakes up a single thread that is waiting on this object's monitor. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notifyAll()() ` Wakes up all threads that are waiting on this object's monitor. | | ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/Object#toString()() ` Returns a string representation of the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait()() ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*. | ||

## Public constructors

### TextSnapshot

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public TextSnapshot (SurroundingText surroundingText, 
                int compositionStart, 
                int compositionEnd, 
                int cursorCapsMode)
```

Creates a new instance of `https://developer.android.com/reference/android/view/inputmethod/TextSnapshot`

<br />

| Parameters ||
|---|---|
| `surroundingText` | `SurroundingText`: `https://developer.android.com/reference/android/view/inputmethod/SurroundingText` of the current edit field. This value cannot be `null`. <br /> |
| `compositionStart` | `int`: The start index of the composing text. `-1` if there is no composing text. Value is -1 or greater <br /> |
| `compositionEnd` | `int`: The end index of the composing text. `-1` if there is no composing text. Value is -1 or greater <br /> |
| `cursorCapsMode` | `int`: The capitalization mode of the first character being edited in the text. See `https://developer.android.com/reference/android/view/inputmethod/EditorInfo#initialCapsMode`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if `compositionStart` and/or `compositionEnd` is less than `-1`. |
| `https://developer.android.com/reference/java/lang/NullPointerException` | if `surroundingText` is `null`. |

## Public methods

### getCompositionEnd

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getCompositionEnd ()
```

<br />

<br />

| Returns ||
|---|---|
| `int` | The end index of the composing text. `-1` if there is no composing text. Value is -1 or greater <br /> |

### getCompositionStart

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getCompositionStart ()
```

<br />

<br />

| Returns ||
|---|---|
| `int` | The end index of the composing text. `-1` if there is no composing text. Value is -1 or greater <br /> |

### getCursorCapsMode

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getCursorCapsMode ()
```

The capitalization mode of the first character being edited in the text.

Values may be any combination of the following values:

- `https://developer.android.com/reference/android/text/TextUtils#CAP_MODE_CHARACTERS`
- `https://developer.android.com/reference/android/text/TextUtils#CAP_MODE_WORDS`
- `https://developer.android.com/reference/android/text/TextUtils#CAP_MODE_SENTENCES`

You should generally just take a non-zero value to mean "start out in caps mode" though.

<br />

<br />

| Returns ||
|---|---|
| `int` | <br /> |

**See also:**

- `https://developer.android.com/reference/android/view/inputmethod/EditorInfo#initialCapsMode`

### getSelectionEnd

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getSelectionEnd ()
```

<br />

<br />

| Returns ||
|---|---|
| `int` | The end index of the selection range. `-1` if it is not available. Value is -1 or greater <br /> |

### getSelectionStart

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getSelectionStart ()
```

<br />

<br />

| Returns ||
|---|---|
| `int` | The start index of the selection range. `-1` if it is not available. Value is -1 or greater <br /> |

### getSurroundingText

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public SurroundingText getSurroundingText ()
```

<br />

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/inputmethod/SurroundingText` | `https://developer.android.com/reference/android/view/inputmethod/SurroundingText` of the current edit field. This value cannot be `null`. <br /> |