I have been searching for a solution could find a proper one. by my self got this far, Not sure what to do next.
I'm testing this on Android 9,Pie.
@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;
}
I also tried 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");
}
}
but it returns this error:
I/: RemoteInput: null
W/System.err: java.lang.IllegalArgumentException: Result key can't be null
at android.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)
how to solve above error, or is there any alternatives. thanks you.