我正在尝试使用Android函数setInterruptFilter(),但是它的行为不稳定。下面的示例代码中,我只是执行set/get,产生了奇怪的结果:
int filter1 = mNotificationManager.getCurrentInterruptionFilter();
mNotificationManager.setInterruptionFilter(NotificationManager.INTERRUPTION_FILTER_ALL);
int filter2 = mNotificationManager.getCurrentInterruptionFilter();
mNotificationManager.setInterruptionFilter(NotificationManager.INTERRUPTION_FILTER_NONE);
int filter3 = mNotificationManager.getCurrentInterruptionFilter();
mNotificationManager.setInterruptionFilter(NotificationManager.INTERRUPTION_FILTER_NONE);
int filter4 = mNotificationManager.getCurrentInterruptionFilter();还要注意的是
INTERRUPTION_FILTER_ALL = 1;
INTERRUPTION_FILTER_NONE = 3;
INTERRUPTION_FILTER_PRIORITY = 2;我正在经历一个痛苦的许可过程,每次我通过ADB加载我的应用程序时,我都会手动进入设置并授予我的应用程序访问通知的权限。我也可以在代码中验证这个权限。
if (!mNotificationManager.isNotificationPolicyAccessGranted()) {...}只有当我在INTERRUPTION_FILTER_ALL (==1)的状态下开始时,我才能得到正确的输出。这到底是怎么回事?
https://stackoverflow.com/questions/38359955
复制相似问题