Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android notification channel - link from system-settings to app-settings

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?

like image 945
hardysim Avatar asked Sep 26 '17 09:09

hardysim


People also ask

How do I set notification channels on Android?

To create a notification channel, follow these steps: Construct a NotificationChannel object with a unique channel ID, a user-visible name, and an importance level. Optionally, specify the description that the user sees in the system settings with setDescription() .

What are channel notifications on Android phone?

Starting with Android 8.0, apps are required to assign their notifications to so-called “notification channels”. These channels determine which signals (notification sound, light, vibration, etc.) incoming notifications trigger.

What is system silent channel notification?

Silent: Your phone won't make a sound or vibrate. But the notification will show up when you swipe down from the top of your screen.


1 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") 
like image 118
jmart Avatar answered Oct 17 '22 23:10

jmart