【问题标题】:How to send reply from expandable notification in android?如何从android中的可扩展通知发送回复?
【发布时间】:2013-09-30 00:53:28
【问题描述】:

请在下方找到具有存档和回复选项的 android gmail 通知屏幕。 在按下回复而不是打开 gmail 应用程序时,编辑文本应显示在将接受回复文本的通知区域中 消息和回复消息应该从通知本身发送。 我们怎样才能做到这一点? 根据下面的链接,我们可以显示归档和回复按钮的设置操作。 http://developer.android.com/training/notify-user/expanded.html

// 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);

按下回复按钮而不是转到 gmail 应用程序/打开整页 ResultActivity 它应该在通知区域本身显示指定高度、宽度和一个回复按钮的编辑文本。 如何做到这一点? 请建议可以遵循哪种方法来实现这一目标。 提前致谢。

【问题讨论】:

  • 我希望回复按钮与 Gmail 应用程序一样工作,我希望我的活动被打开。我用了你的代码。当我点击回复按钮时,它不会打开我的活动。 “CommonConstants.ACTION_REPLY”的值是多少?

标签: android android-layout android-intent notifications


【解决方案1】:

目前这是不可能的。您有一组可能的通知类型,如下所示:http://developer.android.com/guide/topics/ui/notifiers/notifications.html 并且它们都不允许在通知抽屉中输入。您可以做的第二件事是让他们单击回复,然后可以打开一个对话框,其中仅包含必填字段(而不是打开整个活动)

【讨论】:

  • 从下面的视频中我看到 twitter 应用程序提供了我目前正在寻找的回复功能。 youtube.com/watch?feature=player_embedded&v=dkTFv2V4lRo 但我不知道该怎么做。请看一下,如果您有任何建议,请告诉我们。
  • @user1537457 您可能在视频中注意到,通知抽屉实际上关闭并弹出一个新对话框,因此您必须创建一个单独的活动,而不是在通知中创建它单击通知中的按钮后出现的对话框
  • 感谢您的回复。我会尝试用对话框来做到这一点。
猜你喜欢
  • 1970-01-01
  • 2019-10-24
  • 1970-01-01
  • 2015-11-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多