使用 adb 启用通知访问

ham*_*med 4 adb android-notifications

我有一个应用程序可以监听接收通知。安装后,我应该从设置 -> 安全 -> 通知访问启用通知访问

我在模拟器上安装这个应用程序并使用 ADB 运行它。但我不知道如何使用 ADB 中的命令行为其启用通知访问设置。我看到了这个问题,并猜测它的一般答案是正确的,但我找不到实际的设置名称。感谢您的考虑。

113*_*408 7

从 Android 9 开始,接受的答案不再有效。对我有用的是使用:

adb shell cmd notification allow_listener com.mypackage.app/com.mypackage.app.mylistener
Run Code Online (Sandbox Code Playgroud)


ham*_*med 4

我在这里找到了答案, 只需输入:

adb shell settings put secure enabled_notification_listeners %nlisteners:com.example.myapplication/com.example.myapplication.service.ServiceNotificationIntercept
Run Code Online (Sandbox Code Playgroud)

听众后面没有空格

……