Stay organized with collections
Save and categorize content based on your preferences.
OnFileDescriptorEventListener
interface OnFileDescriptorEventListener
A listener which is invoked when file descriptor related events occur.
Summary
Constants |
static Int |
File descriptor event: Indicates that the file descriptor encountered a fatal error.
|
static Int |
File descriptor event: Indicates that the file descriptor is ready for input operations, such as reading.
|
static Int |
File descriptor event: Indicates that the file descriptor is ready for output operations, such as writing.
|
Public methods |
abstract Int |
Called when a file descriptor receives events.
|
Constants
EVENT_ERROR
static val EVENT_ERROR: Int
File descriptor event: Indicates that the file descriptor encountered a fatal error.
File descriptor errors can occur for various reasons. One common error is when the remote peer of a socket or pipe closes its end of the connection.
This event may be generated at any time regardless of whether the EVENT_ERROR
event mask was specified when the listener was added.
Value: 4
static val EVENT_INPUT: Int
File descriptor event: Indicates that the file descriptor is ready for input operations, such as reading.
The listener should read all available data from the file descriptor then return true
to keep the listener active or false
to remove the listener.
In the case of a socket, this event may be generated to indicate that there is at least one incoming connection that the listener should accept.
This event will only be generated if the EVENT_INPUT
event mask was specified when the listener was added.
Value: 1
EVENT_OUTPUT
static val EVENT_OUTPUT: Int
File descriptor event: Indicates that the file descriptor is ready for output operations, such as writing.
The listener should write as much data as it needs. If it could not write everything at once, then it should return true
to keep the listener active. Otherwise, it should return false
to remove the listener then re-register it later when it needs to write something else.
This event will only be generated if the EVENT_OUTPUT
event mask was specified when the listener was added.
Value: 2
Public methods
onFileDescriptorEvents
abstract fun onFileDescriptorEvents(
fd: FileDescriptor,
events: Int
): Int
Called when a file descriptor receives events.
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,["# MessageQueue.OnFileDescriptorEventListener\n\nAdded in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nOnFileDescriptorEventListener\n=============================\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/os/MessageQueue.OnFileDescriptorEventListener \"View this page in Java\") \n\n```\ninterface OnFileDescriptorEventListener\n```\n\n|------------------------------------------------------------|\n| [android.os.MessageQueue.OnFileDescriptorEventListener](#) |\n\nA listener which is invoked when file descriptor related events occur.\n\nSummary\n-------\n\n| Constants ||\n|-----------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------|\n| static [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [EVENT_ERROR](#EVENT_ERROR:kotlin.Int) File descriptor event: Indicates that the file descriptor encountered a fatal error. |\n| static [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [EVENT_INPUT](#EVENT_INPUT:kotlin.Int) File descriptor event: Indicates that the file descriptor is ready for input operations, such as reading. |\n| static [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [EVENT_OUTPUT](#EVENT_OUTPUT:kotlin.Int) File descriptor event: Indicates that the file descriptor is ready for output operations, such as writing. |\n\n| Public methods ||\n|-------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [onFileDescriptorEvents](#onFileDescriptorEvents(java.io.FileDescriptor,%20kotlin.Int))`(`fd:` `[FileDescriptor](../../java/io/FileDescriptor.html#)`, `events:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Called when a file descriptor receives events. |\n\nConstants\n---------\n\n### EVENT_ERROR\n\nAdded in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nstatic val EVENT_ERROR: Int\n```\n\nFile descriptor event: Indicates that the file descriptor encountered a fatal error.\n\nFile descriptor errors can occur for various reasons. One common error is when the remote peer of a socket or pipe closes its end of the connection.\n\nThis event may be generated at any time regardless of whether the [EVENT_ERROR](#EVENT_ERROR:kotlin.Int) event mask was specified when the listener was added. \n\n Value: 4\n\n### EVENT_INPUT\n\nAdded in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nstatic val EVENT_INPUT: Int\n```\n\nFile descriptor event: Indicates that the file descriptor is ready for input operations, such as reading.\n\nThe listener should read all available data from the file descriptor then return `true` to keep the listener active or `false` to remove the listener.\n\nIn the case of a socket, this event may be generated to indicate that there is at least one incoming connection that the listener should accept.\n\nThis event will only be generated if the [EVENT_INPUT](#EVENT_INPUT:kotlin.Int) event mask was specified when the listener was added. \n\n Value: 1\n\n### EVENT_OUTPUT\n\nAdded in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nstatic val EVENT_OUTPUT: Int\n```\n\nFile descriptor event: Indicates that the file descriptor is ready for output operations, such as writing.\n\nThe listener should write as much data as it needs. If it could not write everything at once, then it should return `true` to keep the listener active. Otherwise, it should return `false` to remove the listener then re-register it later when it needs to write something else.\n\nThis event will only be generated if the [EVENT_OUTPUT](#EVENT_OUTPUT:kotlin.Int) event mask was specified when the listener was added. \n\n Value: 2\n\nPublic methods\n--------------\n\n### onFileDescriptorEvents\n\nAdded in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun onFileDescriptorEvents(\n fd: FileDescriptor, \n events: Int\n): Int\n```\n\nCalled when a file descriptor receives events.\n\n| Parameters ||\n|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `fd` | [FileDescriptor](../../java/io/FileDescriptor.html#): The file descriptor. This value cannot be `null`. |\n| `events` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): The set of events that occurred: a combination of the [EVENT_INPUT](#EVENT_INPUT:kotlin.Int), [EVENT_OUTPUT](#EVENT_OUTPUT:kotlin.Int), and [EVENT_ERROR](#EVENT_ERROR:kotlin.Int) event masks. Value is either `0` or a combination of [android.os.MessageQueue.OnFileDescriptorEventListener#EVENT_INPUT](#EVENT_INPUT:kotlin.Int), [android.os.MessageQueue.OnFileDescriptorEventListener#EVENT_OUTPUT](#EVENT_OUTPUT:kotlin.Int), and [android.os.MessageQueue.OnFileDescriptorEventListener#EVENT_ERROR](#EVENT_ERROR:kotlin.Int) |\n\n| Return ||\n|----------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | The new set of events to watch, or 0 to unregister the listener. Value is either `0` or a combination of [android.os.MessageQueue.OnFileDescriptorEventListener#EVENT_INPUT](#EVENT_INPUT:kotlin.Int), [android.os.MessageQueue.OnFileDescriptorEventListener#EVENT_OUTPUT](#EVENT_OUTPUT:kotlin.Int), and [android.os.MessageQueue.OnFileDescriptorEventListener#EVENT_ERROR](#EVENT_ERROR:kotlin.Int) |\n\n**See Also**\n\n- [#EVENT_INPUT](#EVENT_INPUT:kotlin.Int)\n- [#EVENT_OUTPUT](#EVENT_OUTPUT:kotlin.Int)\n- [#EVENT_ERROR](#EVENT_ERROR:kotlin.Int)"]]