Android 12 Developer Preview is here! Try it out, and give us your feedback!

RemoteInputIntentHelper

@RequiresApi(24) class RemoteInputIntentHelper
kotlin.Any
   ↳ androidx.wear.input.RemoteInputIntentHelper

Helper functions for supporting remote inputs through starting an android.content.Intent.

The following example prompts the user to provide input for one RemoteInput by starting an input activity.

public const val KEY_QUICK_REPLY_TEXT: String = "quick_reply";
val remoteInputs: List<RemoteInput> = listOf(
    new RemoteInput.Builder(KEY_QUICK_REPLY_TEXT).setLabel("Quick reply").build()
);
val intent: Intent = createActionRemoteInputIntent();
putRemoteInputsExtra(intent, remoteInputs)
startActivity(intent);

The intent returned via android.app.Activity.onActivityResult will contain the input results if collected. More information about accessing these results can be found in RemoteInput.

Summary

Companion functions
Intent

Create an intent with action for remote input.

String?

Returns the String from the given Intent that specifies what is displayed to cancel the action.

String?

Returns the String from the given Intent that specifies what is displayed to confirm that the action should be executed.

String?

Returns the String from the given Intent that specifies what is displayed while the wearable is preparing to automatically execute the action.

List<RemoteInput>?

Returns the array of RemoteInput from the given Intent that specifies inputs to be collected from a user.

List<CharSequence>?

Returns the array of CharSequence from the given Intent that provides context for creating Smart Reply choices within a RemoteInput session.

String?

Returns the String from the given Intent that specifies what is displayed on top of the confirmation screen to describe the action.

Boolean

Checks whether the given Intent has extra for the array of RemoteInput.

Boolean

Checks whether the action of the given intent is for remote input.

Intent
putCancelLabelExtra(intent: Intent, label: String)

Adds the String to the given Intent that specifies what is displayed to cancel the action.

Intent

Adds the String to the given Intent that specifies what is displayed to confirm that the action should be executed.

Intent

Adds the String to the given Intent that specifies what is displayed while the wearable is preparing to automatically execute the action.

Intent
putRemoteInputsExtra(intent: Intent, remoteInputs: List<RemoteInput>)

Adds the array of RemoteInput to the given Intent that specifies inputs collected from a user.

Intent
putSmartReplyContextExtra(intent: Intent, smartReplyContext: List<CharSequence>)

Adds the array of CharSequence to the given Intent that provides context for creating Smart Reply choices within a RemoteInput session.

Intent
putTitleExtra(intent: Intent, title: String)

Adds the String to the given Intent that specifies what is displayed on top of the confirmation screen to describe the action like "SMS" or "Email".

Companion functions

createActionRemoteInputIntent

@JvmStatic @NonNull fun createActionRemoteInputIntent(): Intent

Create an intent with action for remote input. This intent can be used to start an activity that will prompt the user for input. With the other helpers in this class to specify the intent extras, we can configure the behaviour of the input activity, such as specifying input be collected from a user by populating with an array of RemoteInput with putRemoteInputsExtra.

Return
The created intent with action for remote input.

getCancelLabelExtra

@JvmStatic @Nullable fun getCancelLabelExtra(intent: Intent): String?

Returns the String from the given Intent that specifies what is displayed to cancel the action.

Parameters
intent: Intent The intent with given data.
Return
The string previously added with .putCancelLabelExtra or null if no value is found.

getConfirmLabelExtra

@JvmStatic @Nullable fun getConfirmLabelExtra(intent: Intent):