RecognitionContext
Stay organized with collections
Save and categorize content based on your preferences.
Information about the context in which an ink has been drawn.
Pass this object to a
DigitalInkRecognizer
alongside an ink to improve the recognition quality.
Public Constructor Summary
Inherited Method Summary
From class java.lang.Object
Object
|
clone()
|
boolean |
|
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()
|
Public Constructors
public RecognitionContext ()
Public Methods
public abstract String 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
getWritingArea ()
Size of the writing area.
This is used by some recognition models for disambiguation. Example: lowercase vs
uppercase ("o" vs "O") .
See also WritingArea
.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-20 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-20 UTC."],[],[],null,["# RecognitionContext\n\npublic abstract class **RecognitionContext** extends [Object](//developer.android.com/reference/java/lang/Object.html) \nInformation about the context in which an ink has been drawn.\n\nPass this object to a [DigitalInkRecognizer](/android/reference/com/google/mlkit/vision/digitalink/recognition/DigitalInkRecognizer) alongside an ink to improve the recognition quality. \n\n### Nested Class Summary\n\n|-------|---|---|-----------------------------------------------------------------------------------------------------------------------------------|\n| class | [RecognitionContext.Builder](/android/reference/com/google/mlkit/vision/digitalink/recognition/RecognitionContext.Builder) || Builder for the [RecognitionContext](/android/reference/com/google/mlkit/vision/digitalink/recognition/RecognitionContext) class. |\n\n### Public Constructor Summary\n\n|---|-----------------------------------------------------------------------------------------------------------------------------------|\n| | [RecognitionContext](/android/reference/com/google/mlkit/vision/digitalink/recognition/RecognitionContext#RecognitionContext())() |\n\n### Public Method Summary\n\n|-----------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| static [RecognitionContext.Builder](/android/reference/com/google/mlkit/vision/digitalink/recognition/RecognitionContext.Builder) | [builder](/android/reference/com/google/mlkit/vision/digitalink/recognition/RecognitionContext#builder())() Returns the final [RecognitionContext](/android/reference/com/google/mlkit/vision/digitalink/recognition/RecognitionContext) object. |\n| abstract [String](//developer.android.com/reference/java/lang/String.html) | [getPreContext](/android/reference/com/google/mlkit/vision/digitalink/recognition/RecognitionContext#getPreContext())() Characters immediately before the position where the recognized text should be inserted. |\n| abstract [WritingArea](/android/reference/com/google/mlkit/vision/digitalink/recognition/WritingArea) | [getWritingArea](/android/reference/com/google/mlkit/vision/digitalink/recognition/RecognitionContext#getWritingArea())() Size of the writing area. |\n\n### Inherited Method Summary\n\nFrom class java.lang.Object \n\n|----------------------------------------------------------------------------|--------------------------------------------------------------------------------|\n| [Object](//developer.android.com/reference/java/lang/Object.html) | clone() |\n| boolean | equals([Object](//developer.android.com/reference/java/lang/Object.html) arg0) |\n| void | finalize() |\n| final [Class](//developer.android.com/reference/java/lang/Class.html)\\\u003c?\\\u003e | getClass() |\n| int | hashCode() |\n| final void | notify() |\n| final void | notifyAll() |\n| [String](//developer.android.com/reference/java/lang/String.html) | toString() |\n| final void | wait(long arg0, int arg1) |\n| final void | wait(long arg0) |\n| final void | wait() |\n\nPublic Constructors\n-------------------\n\n#### public **RecognitionContext** ()\n\nPublic Methods\n--------------\n\n#### public static [RecognitionContext.Builder](/android/reference/com/google/mlkit/vision/digitalink/recognition/RecognitionContext.Builder) **builder**\n()\n\nReturns the final [RecognitionContext](/android/reference/com/google/mlkit/vision/digitalink/recognition/RecognitionContext) object. \n\n#### public abstract [String](//developer.android.com/reference/java/lang/String.html) **getPreContext** ()\n\nCharacters immediately before the position where the recognized text should be\ninserted.\n\nExample: a text field contains \"hello\", with the cursor right after \"o\". The user\nhandwrites something that looks like \"world\". If the pre-context is set to \"hello\", the\nrecognition model will be able to output \" world\", with a leading space.\n\nIf the text field contain \"hello\" with the cursor between \"e\" and the first \"l\",\nthen the pre-context must be set to \"he\".\n\nA good rule of thumb for pre-context length is: as many characters as possible,\nincluding spaces, until around 20. The optimal number depends on the exact recognition\nmodel that is used. Getting the best speed/accuracy tradeoff may require a bit of\ntuning. \n\n#### public abstract [WritingArea](/android/reference/com/google/mlkit/vision/digitalink/recognition/WritingArea)\n**getWritingArea** ()\n\nSize of the writing area.\n\nThis is used by some recognition models for disambiguation. Example: lowercase vs\nuppercase (\"o\" vs \"O\") .\n\nSee also [WritingArea](/android/reference/com/google/mlkit/vision/digitalink/recognition/WritingArea)."]]