android通知remoteInput显示问题

时间:2019-01-03 11:57:53

标签: android notifications

我们使用了Android 7的直接回复功能,因此用户可以通过收到的pushnotification回复聊天消息。当他们编辑回复消息时,他们收到了新的推送消息。此时,输入框将阻止通知内容。

这是我的代码:

    String replyLabel = getResources().getString(R.string.reply_label);
    RemoteInput remoteInput = new RemoteInput.Builder(KEY_TEXT_REPLY)
            .setLabel(replyLabel)
            .build();

    Intent intent = new Intent(MainActivity.this, GetMessageReceiver.class);
    PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, intent, PendingIntent.FLAG_ONE_SHOT);

    Notification.Action replyAction = new Notification.Action.Builder(
            R.drawable.ic_chat_blue_24dp, 
            getString(R.string.label), pendingIntent)
            .addRemoteInput(remoteInput)
            .build();

    Notification newMessageNotification = new 
    Notification.Builder(this)
            .setSmallIcon(R.drawable.ic_account_circle_white_24dp)
            .setContentTitle(getString(R.string.title))
            .setContentText(getString(R.string.content))
            .addAction(replyAction)
            .build();
    NotificationManager notificationManager = 
         (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    notificationManager.notify(NOTIFICATION_ID, newMessageNotification);

enter image description here

0 个答案:

没有答案