Search code examples
androidnotificationswear-osmessaging

Wear OS: Get User Input


I'm trying to get text input from a user in a Wear OS app. What I'm looking for is a similar interface to the screenshots below:
Google Notes
Play Store

I have not found anything in the documentation how to achieve something like that. The closest I came across was to use notifications as demonstrated here: https://github.com/android/user-interface-samples/tree/d192c9d2000e43f63cca3eb1b9af05cf2e2ee867/Notifications
This is quite similar to the screenshots from above, the problem however is that this just generates notifications the user then still has to click on. If there is a way such that the notification opens automatically, that would be great


Solution

  • A similar question was already asked here and that solves the issue: https://stackoverflow.com/a/70294785/17818420

    The following code sends an intent to get the user input

    val remoteInputs: List<RemoteInput> = listOf(
        RemoteInput.Builder("quick_reply").setLabel("Quick reply").build()
    )
    val intent: Intent = RemoteInputIntentHelper.createActionRemoteInputIntent()
    putRemoteInputsExtra(intent, remoteInputs)
    startActivityForResult(intent, 0)