How do I clear notifications using ADB shell
Solution 1
Try:
adb shell service call notification 1
Solution 2
If you know the type of the device and Android version, you can clear notifications using ADB without having rooted device.
The idea is to pull down notifications and swipe away all notifications one by one.
-
Pull down:
adb shell input swipe 0 0 0 300
-
Swipe away:
adb shell input swipe 0 400 300 400
It is important to mention, that the (x,y) is something that vary between different type of devices and Android versions. You will need to find by several checks what is the best x,y for you.
The full script
adb shell input swipe 0 0 0 300
num=$(adb shell dumpsys notification | grep NotificationRecord | wc -l)
echo $num
while [ $num -gt 0 ]; do
adb shell input swipe 0 400 300 400
num=$(( $num - 1 ))
done
More details can be found here: https://www.sromku.com/blog/android-adb-clear-notifications
MishaP
Updated on June 16, 2022Comments
-
MishaP almost 2 years
I know I can unlock the screen, pull down the notifications, and press the clear notifications button, but there's got to be a way to clear the notifications through
ADB
, right? I'm guessing it's someIntent
sent through the 'am' command, or maybe something even simpler, but I can't seem to find anything on the net. All I'm getting isJava
code for use with anapk
.Edit: I should probably mention that I'm running on 4.3, sometimes commands may vary between versions.
-
MishaP over 10 years$ adb shell service call notification 1 Result: Parcel(fffffffc ffffffff '........')
-
Alex P. over 10 yearsyou need root to use
service
commands. other than that it should work in 4.3 no problem -
MishaP over 10 yearsthank you, accepted answer. Instead of restarting the device in root, I used su -c: adb shell su -c service call notification 1
-
Corey Ogburn over 10 years@MishaP: It might just be me, but I think you have to wrap
service call notification 1
in quotes to makesu -c
work. -
Piotr Zawadzki about 4 yearsI've tried it and in my case it did not work, because not all notifications can be dismissed e.g. Android Wizard notification that might appear when starting the device for the first time. See: developer.android.com/reference/android/app/…