Home » Android » material design – Android notification channel – link from system-settings to app-settings

material design – Android notification channel – link from system-settings to app-settings

Posted by: admin June 15, 2020 Leave a comment

Questions:

I’m trying to follow the Material Design Guidelines on how to “Link your app’s settings to Android channel settings”. As the images shows, there should be a button on the app-settings “Additional settings in the app” but I don’t know how to set this up.

enter image description here
https://material.io/guidelines/patterns/notifications.html#notifications-settings

I’d expect the NotificationChannel to have an option to set the correct intent or an intent-filter but I cannot find any option for that.


There has been similar behaviors for managing the network and I thought this would work the same way?!


Does anyone knows how to implement this?

How to&Answers:

You just need to add the following intent filter to your settings activity in the manifest:

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

This intent was added in API 21. It added a cog icon to the app’s notification page in the system settings. Clicking on the icon would take the user to the app’s settings activity.

The only change in Api 26 is that now it appears as ‘Additional settings in the app’ instead of an icon.

in case you want to open settings fragment just check intent of your activity:

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