How to suppress notification on lock screen in Android 5 (Lollipop) but let it in notification area?

前端 未结 4 1637
旧巷少年郎
旧巷少年郎 2020-12-31 03:45

After upgrade to Android 5.0 Lollipop it started showing automatically ongoing notification on lock screen.

Sometimes users don\'t want to see all of them so they a

4条回答
  •  Happy的楠姐
    2020-12-31 04:15

    Seems like VISIBILITY_SECRET does the cleanest approach. As per the documentation:

    a notification can be made VISIBILITY_SECRET, which will suppress its icon and ticker until the user has bypassed the lockscreen.

    Per the source (NotificationData in the SystemUI AOSP project), VISIBILITY_SECRET is the only way to do it:

    boolean shouldFilterOut(StatusBarNotification sbn) {
        if (!(mEnvironment.isDeviceProvisioned() ||
                showNotificationEvenIfUnprovisioned(sbn))) {
            return true;
        }
    
        if (!mEnvironment.isNotificationForCurrentProfiles(sbn)) {
            return true;
        }
    
        if (sbn.getNotification().visibility == Notification.VISIBILITY_SECRET &&
                mEnvironment.shouldHideSensitiveContents(sbn.getUserId())) {
            return true;
        }
        return false;
    }
    

    The only other type of notifications that appear to be filtered out are child notifications in a group where a summary is present. So unless you have multiple with a valid reason for a summary, VISIBILITY_SECRET is the best that can currently be done.

提交回复
热议问题