# RecognitionContext

public abstract class **RecognitionContext** extends [Object](https://developer.android.com/reference/java/lang/Object.html)  
Information about the context in which an ink has been drawn.

Pass this object to a `https://developers.google.com/android/reference/com/google/mlkit/vision/digitalink/recognition/DigitalInkRecognizer` alongside an ink to improve the recognition quality.

### Nested Class Summary

|---|---|---|---|
| class | [RecognitionContext.Builder](https://developers.google.com/android/reference/com/google/mlkit/vision/digitalink/recognition/RecognitionContext.Builder) || Builder for the `https://developers.google.com/android/reference/com/google/mlkit/vision/digitalink/recognition/RecognitionContext` class. |

### Public Constructor Summary

|---|---|
|   | [RecognitionContext](https://developers.google.com/android/reference/com/google/mlkit/vision/digitalink/recognition/RecognitionContext#RecognitionContext())() |

### Public Method Summary

|---|---|
| static [RecognitionContext.Builder](https://developers.google.com/android/reference/com/google/mlkit/vision/digitalink/recognition/RecognitionContext.Builder) | [builder](https://developers.google.com/android/reference/com/google/mlkit/vision/digitalink/recognition/RecognitionContext#builder())() Returns the final `https://developers.google.com/android/reference/com/google/mlkit/vision/digitalink/recognition/RecognitionContext` object. |
| abstract [String](https://developer.android.com/reference/java/lang/String.html) | [getPreContext](https://developers.google.com/android/reference/com/google/mlkit/vision/digitalink/recognition/RecognitionContext#getPreContext())() Characters immediately before the position where the recognized text should be inserted. |
| abstract [WritingArea](https://developers.google.com/android/reference/com/google/mlkit/vision/digitalink/recognition/WritingArea) | [getWritingArea](https://developers.google.com/android/reference/com/google/mlkit/vision/digitalink/recognition/RecognitionContext#getWritingArea())() Size of the writing area. |

### Inherited Method Summary

From class java.lang.Object

|---|---|
| [Object](https://developer.android.com/reference/java/lang/Object.html) | clone() |
| boolean | equals([Object](https://developer.android.com/reference/java/lang/Object.html) arg0) |
| void | finalize() |
| final [Class](https://developer.android.com/reference/java/lang/Class.html)\<?\> | getClass() |
| int | hashCode() |
| final void | notify() |
| final void | notifyAll() |
| [String](https://developer.android.com/reference/java/lang/String.html) | toString() |
| final void | wait(long arg0, int arg1) |
| final void | wait(long arg0) |
| final void | wait() |

## Public Constructors

#### public **RecognitionContext** ()

## Public Methods

#### public static [RecognitionContext.Builder](https://developers.google.com/android/reference/com/google/mlkit/vision/digitalink/recognition/RecognitionContext.Builder) **builder**
()

Returns the final `https://developers.google.com/android/reference/com/google/mlkit/vision/digitalink/recognition/RecognitionContext` object.

#### public abstract [String](https://developer.android.com/reference/java/lang/String.html) **getPreContext** ()

Characters immediately before the position where the recognized text should be
inserted.

Example: a text field contains "hello", with the cursor right after "o". The user
handwrites something that looks like "world". If the pre-context is set to "hello", the
recognition model will be able to output " world", with a leading space.

If the text field contain "hello" with the cursor between "e" and the first "l",
then the pre-context must be set to "he".

A good rule of thumb for pre-context length is: as many characters as possible,
including spaces, until around 20. The optimal number depends on the exact recognition
model that is used. Getting the best speed/accuracy tradeoff may require a bit of
tuning.

#### public abstract [WritingArea](https://developers.google.com/android/reference/com/google/mlkit/vision/digitalink/recognition/WritingArea)
**getWritingArea** ()

Size of the writing area.

This is used by some recognition models for disambiguation. Example: lowercase vs
uppercase ("o" vs "O") .

See also `https://developers.google.com/android/reference/com/google/mlkit/vision/digitalink/recognition/WritingArea`.