Android N Inline Reply Push Notifications

In Android Nougat provides Direct reply options in the notification bar, this makes user to respond instantly.


Add Direct Reply From Notification bar

  • Pending intent: Provides the permission to another app to perform operation like its done by your application.
  • Remote input: This is required to show the text box in notification bar & pass the input data to receiver remotely.
  • Action Buttons: Show the buttons in Notification bar & specify action performed on tapping the buttons.
  • Build a pending intent with broadcast receiver, handle response separately using remote input data.
  • setup action item with Remote input object.
  • Pass the actionitem to Notification object & show the notification.
public static final String NOTIFICATION_REPLY = "notification_reply";

public void InLineReplyExample()
    //Provide receiver class to handle the response
    PendingIntent detailsPendingIntent = PendingIntent.getBroadcast(
            new Intent(MainActivity.this, MyReceiver.class),

    RemoteInput remoteInput = new RemoteInput.Builder(NOTIFICATION_REPLY)
            .setLabel("Respond to Message")
    //Setup action item
    NotificationCompat.Action action =
            new NotificationCompat.Action.Builder(android.R.drawable.ic_delete,
                    "Reply Now...", detailsPendingIntent)

    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(MainActivity.this)
            .setContentTitle("Customer identification system")
            .setContentText("Please share your Name")
            .addAction(android.R.drawable.ic_menu_compass, "More", detailsPendingIntent)
            .addAction(android.R.drawable.ic_menu_directions, "Help", detailsPendingIntent);

    NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);


Reading the Remote input Text and update Notification item

Control comes to Pending intent on hitting send button, it could be activity or broadcast receiver. Read the text from Remote input object and update notification. Specify the Receiver in Manifest file

public class NotificationReceiver extends BroadcastReceiver {
    public NotificationReceiver() {

    public void onReceive(Context context, Intent intent) {
        // TODO: This method is called when the BroadcastReceiver is receiving
        // an Intent broadcast.
        Bundle remoteInput = RemoteInput.getResultsFromIntent(intent);
        if (remoteInput != null) {

            CharSequence id = remoteInput.getCharSequence(MainActivity.NOTIFICATION_REPLY);

            NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
                    .setContentTitle("Thank you --- " + id);

            NotificationManager notificationManager = (NotificationManager) context.