Search code examples
androidandroid-manifestandroid-5.0-lollipop

How to add a notification settings activity to the system settings


On Android 5.0 there is an option through Settings -> Sound & notification -> App notification -> Calendar (for example) to go directly to the notification settings of the app.
I also know it's a flag in the manifest as described in this DEV.BYTES talk.
How can it be achieved, what is the flag used?

Here is a screenshot for more clarification:
enter image description here


Solution

  • You need to add the Intent category Notification.INTENT_CATEGORY_NOTIFICATION_PREFERENCES to the Activity you'd like to launch through your AndroidManifest. A simple example would be something like:

        <activity android:name="com.example.packagename.YourSettingsActivity" >
    
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.NOTIFICATION_PREFERENCES" />
            </intent-filter>
        </activity>
    

    For more information, refer to the Settings app and specifically the NotificationAppList and AppNotificationSettings fragments.

    Results

    example