为什么我不能在我的通知中添加文本输入以及如何设置键盘类型?

Why can't I add a text input to my notification and how would I set the keyboard type?

我有一个 Samsung Galaxy S6 运行 android 版本 6.0.1,我正在按照 android 开发人员文档中的示例为我的通知添加内联回复操作.但它不仅对我不起作用,而且我不确定如何将键盘类型更改为此内联响应的 numberDecimal。

我在通知中看到的不是内联文本框,而是一个普通图标和相应的标签附加在通知的普通内容下方。这是我尝试过的:

Intent actualAmountIntent = new Intent(context, ActualAmountReceiver.class);
actualAmountIntent.putExtra("expenseId", expense.id);
PendingIntent actualAmountPendingIntent = PendingIntent.getBroadcast(context, 0, actualAmountIntent, 0);
RemoteInput remoteInput = new RemoteInput.Builder(ActualAmountReceiver.ACTUAL_AMOUNT_KEY)
        .setLabel(context.getString(R.string.actual_amount))
        .build();
Notification.Action action =
    new Notification.Action.Builder(Icon.createWithResource(context, R.drawable.add_icon),
        context.getString(R.string.actual_amount), actualAmountPendingIntent)
            .addRemoteInput(remoteInput)
            .build();
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
Notification.Builder builder = new Notification.Builder(context)
    .setContentTitle(expense.name)
    .setContentText(context.getString(R.string.scheduled_expense_notification))
    .setAutoCancel(true)
    .setSmallIcon(R.drawable.my_app_icon)
    .addAction(action)
    .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));
notificationManager.notify((int)expense.id, builder.build());

ActualAmountReceiver.java:

package my.app.package;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

public class ActualAmountReceiver extends BroadcastReceiver {
    public static final String ACTUAL_AMOUNT_KEY = "actualAmount";

    MyDbHelper dbHelper;

    public void onReceive(Context context, Intent intent) {
        dbHelper = new MyDbHelper(context);
        Expense scheduledExpense = dbHelper.getExpense(intent.getLongExtra("expenseId", -1L));
        Float actualAmount = intent.getFloatExtra(ACTUAL_AMOUNT_KEY, -1.0f);

        System.out.println("actual amount received id(" + scheduledExpense.id + ") " +
                           "name(" + scheduledExpense.name + ") " +
                           "type(" + scheduledExpense.type + ") " +
                           "amount(" + amount + ")");

        dbHelper.close();
    }
}

内联回复适用于 Android 7.0 Nougat。正如您提到的,您的设备中装有 Marshmallow,它无法正常工作。