【问题标题】:Why Do Not Disturb is not activated in Xiaomi devices?为什么小米设备未激活请勿打扰?
【发布时间】:2019-09-13 11:18:24
【问题描述】:

我正在使用此代码设置中断过滤器:

NotificationManager myNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
myNotificationManager.setInterruptionFilter(NotificationManager.INTERRUPTION_FILTER_PRIORITY);

它在每台设备上都运行良好,但由于某些原因,它不适用于使用 Android 9 的 小米 设备。请勿打扰模式未激活设备。它保持不变。如果我问设备当前的中断是什么,它会以 5 的值回答它。这是一个未知且未记录在 Android 开发人员中的值,如 here 所述。

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

【问题讨论】:

    标签: android xiaomi do-not-disturb


    【解决方案1】:

    我猜在小米设备中系统需要更长的时间来激活中断过滤器,所以你不能马上要求结果。 所以,我睡了一秒钟,然后问。 有时它也可能在第一次没有被激活,所以我必须第二次调用 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 error
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-08-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多