java如何以编程方式自动回复通知,如WhatsApp、Instagram
我一直在寻找一个解决方案,我能找到一个合适的。我自己走了这么远,不知道下一步该怎么办
我正在安卓9上测试这个,派
@Override
public void onNotificationPosted(StatusBarNotification sbn) {
Notification.Action action0, action1;
action0= sbn.getNotification().actions[0];
action1 = sbn.getNotification().actions[1];
Log.d(TAG, "Action0: "+ action0);
Log.d(TAG, "Action1 " + action1);
PendingIntent intent = action0.actionIntent;
}
我也试过this
@Override
public void onNotificationPosted(StatusBarNotification sbn) {
Action action = NotificationUtils.getQuickReplyAction(sbn.getNotification(), getPackageName());
if (action != null)
{
Log.i(TAG, "success");
try {
action.sendReply(getApplicationContext(), "Hi, there");
} catch (PendingIntent.CanceledException e) {
Log.i(TAG, "CRAP " + e.toString());
}
}
else
{
Log.i(TAG, "not success");
}
}
但它返回以下错误:
I/: RemoteInput: null
W/System.err: java.lang.IllegalArgumentException: Result key can't be null
at 安卓.app.RemoteInput$Builder.<init>(RemoteInput.java:196)
at models.Action.sendReply(Action.java:69)
W/System.err: at com.abdx79.notificationmanager.NotificationService$PostProcessing.run(NotificationService.java:187)
如何解决上述错误,或者是否有其他选择。 谢谢你
共 (0) 个答案