【问题标题】:What is the difference between areNotificationsEnabled and areNotificationsPausedareNotificationsEnabled 和 areNotificationsPaused 有什么区别
【发布时间】:2021-09-03 08:00:53
【问题描述】:

我能知道areNotificationsEnabled和areNotificationsPaused有什么区别吗

【问题讨论】:

    标签: android android-notifications


    【解决方案1】:

    areNotificationsEnabled

    第一种方法,即 areNotificationsEnabled 将能够判断我们是否完全被用户为您的应用或您想要的包名称阻止的通知 用户可以通过这种方式屏蔽通知

    通知暂停

    第二种方法将能够判断应用程序是否被暂停或暂停,即某个应用程序的通知暂时停止 用户可以通过向左或向右部分滑动通知面板来暂停通知,然后设置他们希望通知暂停的时间

    【讨论】:

    • 所以我应该在启动通知之前检查 areNotificationsEnabled 和 areNotificationsPaused,对吗?谢谢
    • 我通常不这样做,但是如果显示通知对您的应用程序的功能至关重要,那么提醒用户通知被阻止是一个很好的做法
    【解决方案2】:

    我想建议您阅读官方文档,这对您有很大帮助,bi

    areNotificationEnabled:- https://developer.android.com/reference/androidx/core/app/NotificationManagerCompat

    public boolean areNotificationsEnabled()
    

    返回调用包的通知是否未被阻止。

    通知暂停:- https://developer.android.com/reference/android/app/NotificationManager

    public boolean areNotificationsPaused()
    

    返回此包中的通知是否暂时隐藏。可以这样做是因为包裹通过PackageManager#setDistractingPackageRestrictions(String[], int) 标记为分散用户注意力,或者因为包裹被PackageManager#setPackagesSuspended(String[], boolean, PersistableBundle, PersistableBundle, SuspendDialogInfo) 暂停。

    【讨论】:

      猜你喜欢
      • 2022-11-04
      • 2010-10-02
      • 2011-12-12
      • 2010-09-16
      • 2012-03-14
      • 2012-02-06
      • 2011-02-25
      • 2011-11-22
      • 2015-03-26
      相关资源
      最近更新 更多