Stay organized with collections
Save and categorize content based on your preferences.
GestureDescription
class GestureDescription
Accessibility services with the android.R.styleable#AccessibilityService_canPerformGestures
property can dispatch gestures. This class describes those gestures. Gestures are made up of one or more strokes. Gestures are immutable once built and will be dispatched to the specified display.
Spatial dimensions throughout are in screen pixels. Time is measured in milliseconds.
Summary
Nested classes |
|
Builder for a GestureDescription
|
|
Immutable description of stroke that can be part of a gesture.
|
Public methods
getMaxGestureDuration
static fun getMaxGestureDuration(): Long
Get the upper limit on a gesture's duration.
Return |
Long |
The maximum duration in milliseconds. |
getMaxStrokeCount
static fun getMaxStrokeCount(): Int
Get the upper limit for the number of strokes a gesture may contain.
Return |
Int |
The maximum number of strokes. |
getStrokeCount
fun getStrokeCount(): Int
Get the number of stroke in the gesture.
Return |
Int |
the number of strokes in this gesture |
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,["# GestureDescription\n\nAdded in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nGestureDescription\n==================\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/accessibilityservice/GestureDescription \"View this page in Java\") \n\n```\nclass GestureDescription\n```\n\n|---|------------------------------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||\n| ↳ | [android.accessibilityservice.GestureDescription](#) |\n\nAccessibility services with the [android.R.styleable#AccessibilityService_canPerformGestures](../R.styleable.html#AccessibilityService_canPerformGestures:kotlin.Int) property can dispatch gestures. This class describes those gestures. Gestures are made up of one or more strokes. Gestures are immutable once built and will be dispatched to the specified display.\n\nSpatial dimensions throughout are in screen pixels. Time is measured in milliseconds.\n\nSummary\n-------\n\n| Nested classes ||\n|---|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| | [Builder](/reference/kotlin/android/accessibilityservice/GestureDescription.Builder) Builder for a `GestureDescription` |\n| | [StrokeDescription](/reference/kotlin/android/accessibilityservice/GestureDescription.StrokeDescription) Immutable description of stroke that can be part of a gesture. |\n\n| Public methods ||\n|------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [getDisplayId](#getDisplayId())`()` Returns the ID of the display this gesture is sent on, for use with [android.hardware.display.DisplayManager#getDisplay(int)](../hardware/display/DisplayManager.html#getDisplay(kotlin.Int)). |\n| static [Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html) | [getMaxGestureDuration](#getMaxGestureDuration())`()` Get the upper limit on a gesture's duration. |\n| static [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [getMaxStrokeCount](#getMaxStrokeCount())`()` Get the upper limit for the number of strokes a gesture may contain. |\n| [GestureDescription.StrokeDescription](/reference/kotlin/android/accessibilityservice/GestureDescription.StrokeDescription)! | [getStroke](#getStroke(kotlin.Int))`(`index:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Read a stroke from the gesture |\n| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [getStrokeCount](#getStrokeCount())`()` Get the number of stroke in the gesture. |\n\nPublic methods\n--------------\n\n### getDisplayId\n\nAdded in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun getDisplayId(): Int\n```\n\nReturns the ID of the display this gesture is sent on, for use with [android.hardware.display.DisplayManager#getDisplay(int)](../hardware/display/DisplayManager.html#getDisplay(kotlin.Int)).\n\n| Return ||\n|----------------------------------------------------------------------------|-------------------------|\n| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | The logical display id. |\n\n### getMaxGestureDuration\n\nAdded in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nstatic fun getMaxGestureDuration(): Long\n```\n\nGet the upper limit on a gesture's duration.\n\n| Return ||\n|------------------------------------------------------------------------------|---------------------------------------|\n| [Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html) | The maximum duration in milliseconds. |\n\n### getMaxStrokeCount\n\nAdded in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nstatic fun getMaxStrokeCount(): Int\n```\n\nGet the upper limit for the number of strokes a gesture may contain.\n\n| Return ||\n|----------------------------------------------------------------------------|--------------------------------|\n| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | The maximum number of strokes. |\n\n### getStroke\n\nAdded in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun getStroke(index: Int): GestureDescription.StrokeDescription!\n```\n\nRead a stroke from the gesture\n\n| Parameters ||\n|---------|---------------------------------------------------------------------------------------------------------------------------|\n| `index` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): the index of the stroke Value is 0 or greater |\n\n| Return ||\n|------------------------------------------------------------------------------------------------------------------------------|------------------------------|\n| [GestureDescription.StrokeDescription](/reference/kotlin/android/accessibilityservice/GestureDescription.StrokeDescription)! | A description of the stroke. |\n\n### getStrokeCount\n\nAdded in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun getStrokeCount(): Int\n```\n\nGet the number of stroke in the gesture.\n\n| Return ||\n|----------------------------------------------------------------------------|---------------------------------------|\n| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | the number of strokes in this gesture |"]]