0

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.

  • Even if you're able to read the notification you won't be able to reply since WhatsApp and Instagram APIs are closed, you can't make your own client. – m0skit0 May 28 '21 at 10:14
  • Could you solve it, I read this but failed as well: https://medium.com/@polidea/how-to-respond-to-any-messaging-notification-on-android-7befa483e2d7 – Hasan A Yousef Mar 18 '22 at 20:37

0 Answers0