Skip to content

Instantly share code, notes, and snippets.

@KatieBarnett
Last active March 19, 2023 03:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KatieBarnett/d69c5e98003f7a54c28bc9f8913ff3d0 to your computer and use it in GitHub Desktop.
Save KatieBarnett/d69c5e98003f7a54c28bc9f8913ff3d0 to your computer and use it in GitHub Desktop.
Wear OS Input capture result
val launcher = rememberLauncherForActivityResult(
ActivityResultContracts.StartActivityForResult()
) {
it.data?.let { data ->
// Get all the results
val results: Bundle = RemoteInput.getResultsFromIntent(data)
// Use the inputTextKey to select the input we are interested in
val newInputText: CharSequence? = results.getCharSequence(inputTextKey)
// Save the text to our variable as a string. Ensure to handle the null case
userInput = newInputText?.toString() ?: ""
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment