Skip to content

Updated Input Sample - #1043

Open
acianrice wants to merge 4 commits into
android:mainfrom
acianrice:main
Open

Updated Input Sample#1043
acianrice wants to merge 4 commits into
android:mainfrom
acianrice:main

Conversation

@acianrice

Copy link
Copy Markdown

(Hopefully have setup the CLA properly?)

Removed the previous input sample project and added a simpler snippet. Let me know if this suffices.

@acianrice
acianrice requested a review from a team as a code owner August 20, 2026 19:49
@snippet-bot

snippet-bot Bot commented Aug 20, 2026

Copy link
Copy Markdown

Here is the summary of changes.

You are about to add 4 region tags.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

} finally {
projectedActivity.close()
}
} catch (e: Exception) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In coroutines, repeatOnLifecycle cancels its block by throwing a CancellationException when the lifecycle falls below the specified state (RESUMED). To enable coroutine cancellation, don't consume exceptions of type CancellationException (don't catch them, or rethrow them if caught) (https://developer.android.com/kotlin/coroutines/coroutines-best-practices#exceptions).

class MotionGestureInputSnippetActivity : ComponentActivity() {

override fun dispatchGenericMotionEvent(ev: MotionEvent): Boolean {
val actionName = when (ev.actionMasked) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be helpful to clarify what these MotionEvents map to.
ACTION_DOWN : first contact with the glasses touchpad
ACTION_MOVE : contact moving across the glasses touchpad.
ACTION_UP : contact lifted from the glasses touchpad.

@trambui09 trambui09 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks much better! Left some comments. I also kickstarted the build process, but looks like the build failed...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants