RemoteInput


public final class RemoteInput
extends Object implements Parcelable

java.lang.Object
   ↳ android.app.RemoteInput


A RemoteInput object specifies input to be collected from a user to be passed along with an intent inside a PendingIntent that is sent. Always use RemoteInput.Builder to create instances of this class.

See Replying to notifications for more information on how to use this class.

The following example adds a RemoteInput to a Notification.Action, sets the result key as quick_reply, and sets the label as 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 Builder constructor) from the Bundle returned by getResultsFromIntent(Intent).

 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 PendingIntent is fired, the intent inside will contain the input results if collected. To access these results, use the getResultsFromIntent(Intent) function. The result values will present under the result key passed to the 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);
 }

Summary

Nested classes

class RemoteInput.Builder

Builder class for RemoteInput objects.