A {@code RemoteInput} object specifies input to be collected from a user to be passed along with
an intent inside a {@link android.app.PendingIntent} that is sent.
Always use {@link RemoteInput.Builder} to create instances of this class.
See
Receiving Voice Input from
a Notification for more information on how to use this class.
The following example adds a {@code RemoteInput} to a {@link Notification.Action},
sets the result key as {@code quick_reply}, and sets the label as {@code Quick reply}.
Users are prompted to input a response when they trigger the action. The results are sent along
with the intent and can be retrieved with the result key (provided to the {@link Builder}
constructor) from the Bundle returned by {@link #getResultsFromIntent}.
public static final String KEY_QUICK_REPLY_TEXT = "quick_reply";
Notification.Action action = new Notification.Action.Builder(
R.drawable.reply, "Reply", actionIntent)
.addRemoteInput(new RemoteInput.Builder(KEY_QUICK_REPLY_TEXT)
.setLabel("Quick reply").build())
.build();
When the {@link android.app.PendingIntent} is fired, the intent inside will contain the
input results if collected. To access these results, use the {@link #getResultsFromIntent}
function. The result values will present under the result key passed to the {@link Builder}
constructor.
public static final String KEY_QUICK_REPLY_TEXT = "quick_reply";
Bundle results = RemoteInput.getResultsFromIntent(intent);
if (results != null) {
CharSequence quickReplyResult = results.getCharSequence(KEY_QUICK_REPLY_TEXT);
} |