我使用以下代码设置中断筛选器:
NotificationManager myNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
myNotificationManager.setInterruptionFilter(NotificationManager.INTERRUPTION_FILTER_PRIORITY);它在每个设备上都运行得很好,但由于某种原因,它没有在小米设备上使用安卓9。在这些设备中,不干扰模式没有激活。它保持不变。如果我问设备当前的中断是什么,它的回答值为5,这在Android开发者中是一个未知的、没有记录在案的值,正如所述的这里。
int iCurrentInterruption = oNotificationManager.getCurrentInterruptionFilter();iCurrentInterruption的值为5。以下任何一项都没有:
INTERRUPTION_FILTER_UNKNOWN = 0
INTERRUPTION_FILTER_ALL = 1
INTERRUPTION_FILTER_PRIORITY = 2
INTERRUPTION_FILTER_NONE = 3
INTERRUPTION_FILTER_ALARMS = 4发布于 2019-09-15 18:40:15
我想在小米设备中,系统需要更长的时间来激活中断过滤器,所以你不能马上要求结果。所以,我睡了一会儿,然后问。它也发生了,有时它没有在第一次被激活,所以我不得不第二次调用setInterruptionFilter。
就像这样:
setInterruptionFilter(INTERRUPTION_FILTER_PRIORITY)
wait
If INTERRUPTION_FILTER_PRIORITY==getCurrentInterruptionFilter() then return OK
//Second try:
setInterruptionFilter(INTERRUPTION_FILTER_PRIORITY)
wait
If INTERRUPTION_FILTER_PRIORITY==getCurrentInterruptionFilter() then return Ok
return errorhttps://stackoverflow.com/questions/57922661
复制相似问题