是否可以向通知RemoteInputAndroid添加初始文本?

问题描述

我正在创建Android笔记应用,并希望添加功能以编辑存储在通知中的笔记。那么我可以从当前注释(通知)向Android RemoteInput添加初始文本,并允许用户对其进行更改吗?

example of note(notification)

示例:我需要将通知中的“ hello world”文本设置为“类型注释” RemoteInput字段。

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {

        Intent editIntent = new Intent(ACTION_EDIT,null,context,EditReceiver.class);
        editIntent.setAction(ACTION_EDIT);
        editIntent.putExtra(NOTIFICATION_ID,id);

        PendingIntent replyPendingIntent =
                PendingIntent.getbroadcast(context,id,editIntent,PendingIntent.FLAG_UPDATE_CURRENT);


        RemoteInput remoteInput = new RemoteInput.Builder(EDIT_TEXT)
                .setLabel(TYPE_NOTE)
                .build();

        NotificationCompat.Action action =
                new NotificationCompat.Action.Builder(android.R.drawable.ic_menu_send,EDIT,replyPendingIntent)
                        .addRemoteInput(remoteInput)
                        .build();

        mBuilder.addAction(action);
        mBuilder.setLargeIcon(BitmapFactory.decodeResource(context.getResources(),R.mipmap.pushpinsm));
}

解决方法

我认为无法设置初始消息。

如果您关于设置标签的问题,此代码将在 RemoteInput 中设置标签。

for key,value in handler.items():
    try:
        unpacked = struct.unpack('>BBBf',value.encode('latin1'))
        if unpacked[:3] == (159,120,4):
            '''Checking if data Opaque or not.'''

            print(unpacked[-1])
        else:
            print(value)
    except AttributeError:
        print(value)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...