Sample Header Ad - 728x90

Interact with notification action from ADB Shell

11 votes
0 answers
4153 views
I have an Android(7) phone [also fine if you can provide a solution for Android 10] and a Linux pc. By enabling USB debugging and using the terminal of my pc, I am able to read the notifications of my phone using the command:
shell dumpsys notification --noredact
Now, there are some notifications in Android in which we can interact with the app directly from the notification. For example, in a WhatsApp notification, there are usually two buttons: *Reply* & *Mark as read*. On YouTube, there are options like *Play, Turn off, Watch later*. In the output of the above command, these options are visible in the following form:
actions={
         "Reply" -> PendingIntent{6becf48: PendingIntentRecord{87b8050 com.whatsapp startService (whitelist: +30s0ms)}}
         "Mark as read" -> PendingIntent{c1661e1: PendingIntentRecord{b8e3249 com.whatsapp startService (whitelist: +30s0ms)}}
      }
I have two questions: 1. Can we interact with these options from adb shell? For example, is there any command like
shell  'Message to be sent in WhatsApp with reply option'
which will send the text as a reply in WhatsApp without opening the app? 2. Is it possible to swipe the notifications using any ADB command? (Not the
shell input swipe x0 y0 x1 y1
, it requires to unlock the phone each time) Thank you in advance! **Edit:** Here is what I found that may be relevant to this question. I think that I have to somehow launch the specific intent linked to the mentioned PendingIntent id (in this case
or
) Using the command
shell dumpsys activity intents > output.txt
and then searching for
in
.txt
, I found the name of the intent. It was as follows:
* PendingIntentRecord{87b8050 com.whatsapp startService (whitelist: +30s0ms)}
    uid=10104 packageName=com.whatsapp type=startService flags=0x0
    requestIntent=act=com.whatsapp.intent.action.DIRECT_REPLY_FROM_MESSAGE dat=content://com.whatsapp.provider.contact/contacts/2256 cmp=com.whatsapp/.notification.DirectReplyService (has extras)
    whitelistDuration=+30s0ms
Now I think that it may be possible to launch the intent
.whatsapp.intent.action.DIRECT_REPLY_FROM_MESSAGE
using
shell am
command, and passing the intent id and message as some parameters. (Just like we can launch WhatsApp from adb with
command, it should be possible to launch the pendingIntent also.) **Edit 2:** Using this command:
adb shell am startservice -a com.whatsapp.intent.action.DIRECT_REPLY_FROM_MESSAGE -d content://com.whatsapp.provider.contact/contacts/2256 -n com.whatsapp/.notification.DirectReplyService --es 'com.whatsapp.Intent.EXTRA_TEXT' 'Hi. Okay.'
The output was as follows:
Starting service: Intent { act=com.whatsapp.intent.action.DIRECT_REPLY_FROM_MESSAGE dat=content://com.whatsapp.provider.contact/contacts/2256 cmp=com.whatsapp/.notification.DirectReplyService (has extras) }
Error: Requires permission not exported from uid 10104
Asked by Soham Saha (111 rep)
Oct 25, 2020, 02:22 PM
Last activity: Sep 15, 2025, 10:05 PM