How to send reply from expandable notification in

2019-07-20 03:20发布

Please find below android gmail notification screen which has option of archive and reply. On pressing reply instead of opening gmail app, the edittext should be displayed in notification area which will accept the reply text message and reply message should be sent from notification itself. How we can achive this ? As per the link below we can display set action to archive and reply buttons. http://developer.android.com/training/notify-user/expanded.htmlenter image description here

// Sets up the archive and reply action buttons that will appear in the
// big view of the notification.

Intent archiveIntent = new Intent(this, ResultActivity.class);
archiveIntent.setAction(CommonConstants.ACTION_ARCHIVE);
PendingIntent piArchive = PendingIntent.getService(this, 0, archiveIntent, 0);

Intent replyIntent = new Intent(this, ResultActivity.class);
replyIntent.setAction(CommonConstants.ACTION_REPLY);
PendingIntent piReply = PendingIntent.getService(this, 0, replyIntent, 0);


NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_stat_notification)
.setContentTitle(getString(R.string.notification)) .setContentText(getString(R.string.ping))
.setDefaults(Notification.DEFAULT_ALL) 
.setStyle(new NotificationCompat.BigTextStyle()
.bigText(msg))
.addAction (R.drawable.ic_stat_archive,getString(R.string.archive), piArchive)
.addAction (R.drawable.ic_stat_reply,getString(R.string.reply), piReply);

On pressing reply button instead of going to gmail app/ opening the full page ResultActivity it should display edittext of specified height , width and one reply button in notification area itself. How this can be achieved? Kindly suggest which approach can be followed in order to achieve this. Thanks in advance.

1条回答
男人必须洒脱
2楼-- · 2019-07-20 04:01

This is currently not possible. You have a set number of possible notification types as specified here: http://developer.android.com/guide/topics/ui/notifiers/notifications.html and none of them allow input in the notification drawer. The second best thing you can do is have them click reply and a dialog can open with only the required fields (and not open a whole activity)

查看更多
登录 后发表回答