Stay organized with collections
Save and categorize content based on your preferences.
DataShareWriteAdapter
interface DataShareWriteAdapter
Adapter class used by apps to share data with the Content Capture service.
Summary
Public methods |
open Unit |
Method invoked when an error occurred, for example sessions has not been started or terminated unsuccessfully.
|
abstract Unit |
Data share sessions has been rejected by the Content Capture service.
|
abstract Unit |
Method invoked when the data share session has been started and the app needs to start writing into the file used for sharing.
|
Public methods
onError
open fun onError(errorCode: Int): Unit
Method invoked when an error occurred, for example sessions has not been started or terminated unsuccessfully.
onRejected
abstract fun onRejected(): Unit
Data share sessions has been rejected by the Content Capture service.
onWrite
abstract fun onWrite(destination: ParcelFileDescriptor): Unit
Method invoked when the data share session has been started and the app needs to start writing into the file used for sharing.
App needs to handle explicitly cases when the file descriptor is closed and handle gracefully if IOExceptions happen.
Parameters |
destination |
ParcelFileDescriptor: file descriptor used to write data into. This value cannot be null . |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 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-02-10 UTC."],[],[],null,["# DataShareWriteAdapter\n\nAdded in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nDataShareWriteAdapter\n=====================\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/view/contentcapture/DataShareWriteAdapter \"View this page in Java\") \n\n```\ninterface DataShareWriteAdapter\n```\n\n|--------------------------------------------------------|\n| [android.view.contentcapture.DataShareWriteAdapter](#) |\n\nAdapter class used by apps to share data with the Content Capture service.\n\nSummary\n-------\n\n| Public methods ||\n|---------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onError](#onError(kotlin.Int))`(`errorCode:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Method invoked when an error occurred, for example sessions has not been started or terminated unsuccessfully. |\n| abstract [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onRejected](#onRejected())`()` Data share sessions has been rejected by the Content Capture service. |\n| abstract [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onWrite](#onWrite(android.os.ParcelFileDescriptor))`(`destination:` `[ParcelFileDescriptor](../../os/ParcelFileDescriptor.html#)`)` Method invoked when the data share session has been started and the app needs to start writing into the file used for sharing. |\n\nPublic methods\n--------------\n\n### onError\n\nAdded in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun onError(errorCode: Int): Unit\n```\n\nMethod invoked when an error occurred, for example sessions has not been started or terminated unsuccessfully.\n\n| Parameters ||\n|-------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `errorCode` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): the error code corresponding to an ERROR_\\* value. Value is [android.view.contentcapture.ContentCaptureManager#DATA_SHARE_ERROR_UNKNOWN](/reference/kotlin/android/view/contentcapture/ContentCaptureManager#DATA_SHARE_ERROR_UNKNOWN:kotlin.Int), [android.view.contentcapture.ContentCaptureManager#DATA_SHARE_ERROR_CONCURRENT_REQUEST](/reference/kotlin/android/view/contentcapture/ContentCaptureManager#DATA_SHARE_ERROR_CONCURRENT_REQUEST:kotlin.Int), or [android.view.contentcapture.ContentCaptureManager#DATA_SHARE_ERROR_TIMEOUT_INTERRUPTED](/reference/kotlin/android/view/contentcapture/ContentCaptureManager#DATA_SHARE_ERROR_TIMEOUT_INTERRUPTED:kotlin.Int) |\n\n### onRejected\n\nAdded in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun onRejected(): Unit\n```\n\nData share sessions has been rejected by the Content Capture service. \n\n### onWrite\n\nAdded in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun onWrite(destination: ParcelFileDescriptor): Unit\n```\n\nMethod invoked when the data share session has been started and the app needs to start writing into the file used for sharing.\n\nApp needs to handle explicitly cases when the file descriptor is closed and handle gracefully if IOExceptions happen.\n\n| Parameters ||\n|---------------|------------------------------------------------------------------------------------------------------------------------------------|\n| `destination` | [ParcelFileDescriptor](../../os/ParcelFileDescriptor.html#): file descriptor used to write data into. This value cannot be `null`. |"]]