iink SDK on Device

Add the iink SDK off-screen recognizer to my project

I tried to add the iink SDK off-screen recognizer to my project and encountered the following error. Can you help me check it out? Please explain if you need more details.

```

  // Create offscreen editor
Log.d(TAG, "Starting to create offscreen editor...")
val offscreenEditor = engine.createOffscreenEditor(1f, 1f)
if (offscreenEditor == null) {
Log.e(TAG, "Failed to create offscreen editor, result is null")
return
}

Log.d(TAG, "Offscreen editor created successfully")

// Configure the editor
try {
val configuration = offscreenEditor.configuration
configuration.inject(config)
Log.d(TAG, "Editor configuration injected successfully")
} catch (e: Exception) {
Log.e(TAG, "Failed to inject editor configuration: ${e.message}")
e.printStackTrace()
}

// Create or open package
val contentFile = File(dataDir, "OffscreenEditor.iink")
Log.d(TAG, "Going to create package file: ${contentFile.absolutePath}")

try {
// Use a separate variable to avoid expressions
var contentPackage = engine.createPackage(contentFile)
if (contentPackage == null) {
Log.e(TAG, "Failed to create content package, result is null")
return
}

Log.d(TAG, "Content package created successfully")

// Create part
var part: ContentPart? = null
try {
part = contentPackage.createPart("Number Test Content")
Log.d(TAG, "Content part created successfully: ${part != null}")
} catch (e: Exception) {
Log.e(TAG, "Failed to create content part: ${e.message}")
e.printStackTrace()
}

// Set content part
if (part != null) {
try {
offscreenEditor.part = part
Log.d(TAG, "Editor content part set successfully")
} catch (e: Exception) {
Log.e(TAG, "Failed to set editor content part: ${e.message}")
e.printStackTrace()
}

// Use main thread handler to delay test execution
android.os.Handler(android.os.Looper.getMainLooper()).postDelayed({
Log.d(TAG, "Starting drawing test...")
testDrawNumber(offscreenEditor)
}, 2000)
} else {
Log.e(TAG, "Skipping test because content part is null")
}

// Ensure the content package is closed
try {
contentPackage.close()
Log.d(TAG, "Content package closed")
} catch (e: Exception) {
Log.e(TAG, "Failed to close content package: ${e.message}")
e.printStackTrace()
}
} catch (e: Exception) {
Log.e(TAG, "Content package operation failed: ${e.message}")
e.printStackTrace()
}
} catch (e: Exception) {
Log.e(TAG, "Critical error occurred during test initialization: ${e.message}")
e.printStackTrace()
}
}

```



image



1 Comment

Hello,


Thank you for contacting us.


As indicated in the error call stack, the content part type that you are using for your part is not valid:

 
part = contentPackage.createPart("Number Test Content")


When working with an OffScreenEditor you must use a "Raw Content" part:


part = contentPackage.createPart("Raw Content")


Best regards,


Gwenaëlle


Login or Signup to post a comment