Android 8.0 and above brought notification channels. Is there any way to list all notification channels, create channels and/or disable channels for an app from ADB? Root solutions are acceptable too. Thank you.
-
I am trying to find the same. Have you got any solution? – RHS.Dev Feb 23 '21 at 18:00
-
@RahulSaliya no. – SayantanRC Feb 24 '21 at 19:15
-
I did found workaround by disabling notification entirely when notifications are not required for my app. What is/was your requirement? – RHS.Dev Feb 26 '21 at 02:27
-
Reading notification preferences and storing in a file. I was working on a root based backup app. – SayantanRC Feb 26 '21 at 23:58
-
Try the answer below if you are still working on the project. My work is done in just enabling and disabling notifications so I haven't tried anything with notification channels. – RHS.Dev Feb 27 '21 at 10:18
2 Answers
You can create a notification channel, delete a channel if you want using service call superuser command.
Here is a small example by which you can enable or disable notifications for any app. By using that reference you can get notification channels information.
public final Shell.Interactive su = new Shell.Builder().useSU().open();
function setNotification(String packageName, int uid, boolean enable){
try {
@SuppressLint("PrivateApi") Field field = Class.forName("android.app.INotificationManager").getDeclaredClasses()[0].getDeclaredField("TRANSACTION_setNotificationsEnabledForPackage");
field.setAccessible(true);
int id = field.getInt(null);
su.addCommand(String.format(Locale.ENGLISH, "service call notification %d s16 %s i32 %d i32 %d", id, packageName, uid, enable ? 1 : 0));
} catch (ClassNotFoundException | IllegalAccessException | NoSuchFieldException e) {
e.printStackTrace();
}
}
here service call is used to call the underlying service, id is used to identify the function and s16 is for String input and i32 is for int input they are just parameters of the function we are calling in notification service.
You can find explanation to service call from here:
Where to find info on Android's "service call" shell command?
You can find reference to INotificationManager from here:
As you can see there is a function called setNotificationsEnabledForPackage in the INotificationManager which I have used in the example. There are many functions related to notification channel like getNotificationChannel just use which suits you and replace it with setNotificationsEnabledForPackage and pass appropriate parameters.
Here su is from this library:

- 412
- 6
- 18
-
-
uid parameter is user ID and if your device does not have multiple user it will be 0 by default. You can get list of uids using "pm" command. – RHS.Dev Jul 20 '22 at 14:23
-
I thought that maybe it's `Process.myUid()` . Isn't there an official API to get the "uid" you are talking about (of the current user)? Can you please share the code to get it, based on what you've found? Also isn't there a better way than this reflection? Maybe using adb? – android developer Jul 20 '22 at 20:07
You could try
adb shell dumpsys notification
This will show the detail about NotificationManagerService.

- 2,711
- 5
- 16
- 34

- 777
- 2
- 6
- 24
-
This should be the accepted answer, the call provides all necessary information about all notification channels – Sebastian Schneider Jan 14 '22 at 12:12