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

# HandwritingGesture

*** ** * ** ***

` public abstract class HandwritingGesture `   
` extends https://developer.android.com/reference/java/lang/Object ` ` `

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

Known direct subclasses [InsertGesture](https://developer.android.com/reference/android/view/inputmethod/InsertGesture), [InsertModeGesture](https://developer.android.com/reference/android/view/inputmethod/InsertModeGesture), [JoinOrSplitGesture](https://developer.android.com/reference/android/view/inputmethod/JoinOrSplitGesture), [PreviewableHandwritingGesture](https://developer.android.com/reference/android/view/inputmethod/PreviewableHandwritingGesture), [RemoveSpaceGesture](https://developer.android.com/reference/android/view/inputmethod/RemoveSpaceGesture) [InsertGesture](https://developer.android.com/reference/android/view/inputmethod/InsertGesture) A sub-class of `https://developer.android.com/reference/android/view/inputmethod/HandwritingGesture` for inserting text at the defined insertion point. [InsertModeGesture](https://developer.android.com/reference/android/view/inputmethod/InsertModeGesture) A sub-class of `https://developer.android.com/reference/android/view/inputmethod/HandwritingGesture` for starting an insert mode which inserts a space in the editor to let users hand write freely at the designated insertion point. [JoinOrSplitGesture](https://developer.android.com/reference/android/view/inputmethod/JoinOrSplitGesture) A subclass of `https://developer.android.com/reference/android/view/inputmethod/HandwritingGesture` for deleting or inserting whitespace in text. [PreviewableHandwritingGesture](https://developer.android.com/reference/android/view/inputmethod/PreviewableHandwritingGesture) A `https://developer.android.com/reference/android/view/inputmethod/HandwritingGesture` that can be `https://developer.android.com/reference/android/view/inputmethod/InputConnection#previewHandwritingGesture(android.view.inputmethod.PreviewableHandwritingGesture,%20android.os.CancellationSignal)`. [RemoveSpaceGesture](https://developer.android.com/reference/android/view/inputmethod/RemoveSpaceGesture) A subclass of `https://developer.android.com/reference/android/view/inputmethod/HandwritingGesture` for removing whitespace from text. Known indirect subclasses [DeleteGesture](https://developer.android.com/reference/android/view/inputmethod/DeleteGesture), [DeleteRangeGesture](https://developer.android.com/reference/android/view/inputmethod/DeleteRangeGesture), [SelectGesture](https://developer.android.com/reference/android/view/inputmethod/SelectGesture), [SelectRangeGesture](https://developer.android.com/reference/android/view/inputmethod/SelectRangeGesture) [DeleteGesture](https://developer.android.com/reference/android/view/inputmethod/DeleteGesture) A sub-class of `https://developer.android.com/reference/android/view/inputmethod/HandwritingGesture` for deleting an area of text using single rectangle. [DeleteRangeGesture](https://developer.android.com/reference/android/view/inputmethod/DeleteRangeGesture) A subclass of `https://developer.android.com/reference/android/view/inputmethod/HandwritingGesture` for deleting a range of text by defining start and end rectangles. [SelectGesture](https://developer.android.com/reference/android/view/inputmethod/SelectGesture) A sub-class of `https://developer.android.com/reference/android/view/inputmethod/HandwritingGesture` for selecting an area of text using single rectangle. [SelectRangeGesture](https://developer.android.com/reference/android/view/inputmethod/SelectRangeGesture) A subclass of `https://developer.android.com/reference/android/view/inputmethod/HandwritingGesture` for selecting a range of text by defining start and end rectangles.   

*** ** * ** ***

Base class for stylus handwriting gestures.

During a stylus handwriting session, user can perform a stylus gesture operation like `https://developer.android.com/reference/android/view/inputmethod/SelectGesture`, `https://developer.android.com/reference/android/view/inputmethod/DeleteGesture`, `https://developer.android.com/reference/android/view/inputmethod/InsertGesture` on an area of text. IME is responsible for listening to stylus `https://developer.android.com/reference/android/view/MotionEvent`s using `https://developer.android.com/reference/android/inputmethodservice/InputMethodService#onStylusHandwritingMotionEvent(android.view.MotionEvent)` and interpret if it can translate to a gesture operation.

While creating gesture operations `https://developer.android.com/reference/android/view/inputmethod/SelectGesture` and `https://developer.android.com/reference/android/view/inputmethod/DeleteGesture`, `Granularity` helps pick the correct granular level of text like word level `https://developer.android.com/reference/android/view/inputmethod/HandwritingGesture#GRANULARITY_WORD`, or character level `https://developer.android.com/reference/android/view/inputmethod/HandwritingGesture#GRANULARITY_CHARACTER`.
**See also:**

- `https://developer.android.com/reference/android/view/inputmethod/InputConnection#performHandwritingGesture(android.view.inputmethod.HandwritingGesture,%20java.util.concurrent.Executor,%20java.util.function.IntConsumer)`
- `https://developer.android.com/reference/android/view/inputmethod/InputConnection#previewHandwritingGesture(android.view.inputmethod.PreviewableHandwritingGesture,%20android.os.CancellationSignal)`
- `https://developer.android.com/reference/android/inputmethodservice/InputMethodService#onStartStylusHandwriting()`

## Summary

| ### Constants ||
|---|---|
| `int` | `https://developer.android.com/reference/android/view/inputmethod/HandwritingGesture#GRANULARITY_CHARACTER` Operate on text per character basis. |
| `int` | `https://developer.android.com/reference/android/view/inputmethod/HandwritingGesture#GRANULARITY_WORD` Operate text per word basis. |

| ### Public methods ||
|---|---|
| ` final https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/view/inputmethod/HandwritingGesture#getFallbackText()() ` The fallback text that will be committed at current cursor position if there is no applicable text beneath the area of gesture. |

### 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*.

## Constants

### GRANULARITY_CHARACTER

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

```
public static final int GRANULARITY_CHARACTER
```

Operate on text per character basis. i.e. each character is selected based on its intersection with selection rectangle.

Strategy of operating at a granular level is maintained in the UI toolkit. A character/word/line is included if its center is within the gesture rectangle. e.g. if a selection `https://developer.android.com/reference/android/graphics/RectF` with `https://developer.android.com/reference/android/view/inputmethod/HandwritingGesture#GRANULARITY_CHARACTER` includes width-wise center of the character, it should be selected. Similarly, text in a line should be included in the operation if rectangle includes line height center.

<br />

<br />

Constant Value: 2 (0x00000002)

### GRANULARITY_WORD

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

```
public static final int GRANULARITY_WORD
```

Operate text per word basis. e.g. if selection includes width-wise center of the word, whole word is selected.

Strategy of operating at a granular level is maintained in the UI toolkit. A character/word/line is included if its center is within the gesture rectangle. e.g. if a selection `https://developer.android.com/reference/android/graphics/RectF` with `https://developer.android.com/reference/android/view/inputmethod/HandwritingGesture#GRANULARITY_WORD` includes width-wise center of the word, it should be selected. Similarly, text in a line should be included in the operation if rectangle includes line height center.
Refer to https://www.unicode.org/reports/tr29/#Word_Boundaries for more detail on how word breaks are decided.

<br />

<br />

Constant Value: 1 (0x00000001)

## Public methods

### getFallbackText

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

```
public final String getFallbackText ()
```

The fallback text that will be committed at current cursor position if there is no applicable text beneath the area of gesture. For example, select can fail if gesture is drawn over area that has no text beneath. example 2: join can fail if the gesture is drawn over text but there is no whitespace.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | This value may be `null`. <br /> |