Android 7.0/API24:如何检查通知访问(Settings.Secure.enabled_notificat



在Android 6.0/API23及更早的版本中,以下操作可以正常工作:

String settingEnabled = android.provider.Settings.Secure.getString(this.getContentResolver(), "enabled_notification_listeners");

在Android 7.0 Nougat/API24中,这似乎不再支持,因为上面的代码返回null

实际上这里从来没有提到过:https://developer.android.com/reference/android/provider/Settings.Secure.html

我们如何检查我们的应用程序是否有通知访问在Android 7.0牛轧糖API24?

编辑:似乎实际上,在您第一次获得设置中的访问权限后,上面的代码返回正确的状态。

使用

Set<String> packageNames = NotificationManagerCompat.getEnabledListenerPackages (context);

相关内容

最新更新