【问题标题】:Android notification channel - link from system-settings to app-settingsAndroid 通知通道 - 从系统设置链接到应用设置
【发布时间】:2017-09-26 09:44:09
【问题描述】:

我正在尝试遵循有关如何“将您的应用设置链接到 Android 频道设置”的材料设计指南。如图所示,应用设置“应用中的其他设置”上应该有一个按钮,但我不知道如何设置。

https://material.io/guidelines/patterns/notifications.html#notifications-settings

我希望NotificationChannel 可以选择设置正确的意图或意图过滤器,但我找不到任何选项。


managing the network 也有类似的行为,我认为这会以同样的方式工作?!


有人知道如何实现吗?

【问题讨论】:

    标签: android material-design


    【解决方案1】:

    您只需在清单中的设置活动中添加以下意图过滤器:

    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.NOTIFICATION_PREFERENCES" />
    </intent-filter>
    

    此意图是在 API 21 中添加的。它在系统设置中的应用通知页面中添加了一个 cog 图标。单击该图标会将用户带到应用程序的设置活动。

    Api 26 的唯一变化是现在它显示为“应用程序中的其他设置”而不是图标。

    如果您想打开设置片段,只需检查您的活动意图:

    intent.getCategories().contains("android.intent.category.NOTIFICATION_PREFERENCES") 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-05-21
      • 2019-05-21
      • 2015-05-01
      • 2019-06-27
      • 1970-01-01
      • 2011-07-18
      • 2023-02-05
      • 2015-11-28
      相关资源
      最近更新 更多