Exposing Notification Settings to the Android System

Have you ever looked at the Android System settings page for a specific application and wondered about the option to view “Additional settings in the app”? If you haven’t seen this before in your settings, or aren’t aware of it, this is what it looks like:

This option allows developers to essentially provide a link to a push notification settings screen in their application — this allows users to quickly and easily continue altering their notification settings for the chosen app directly from the system. The ability to hook into this was added at API level 21 (Android 5.0), but not all applications are making use of the feature.

To add this to your app we simply need to make use of the Notification Preferences Intent Category to define which activity to be launched when this link within the system settings is pressed. By default if our application has not make use of this Intent Category then the option within settings will not be displayed. If you want to display this option within your settings for your users then all you need to do is the following:

<activity android:name=”.PushSettingsActivity”>
    <intent-filter>
        <action android:name=”android.intent.action.MAIN” />
            <category android:name=”android.intent.category
                .NOTIFICATION_PREFERENCES” />
    </intent-filter>
</activity>

Now, the “Additional settings in the app” option will display on our application notification settings and when clicked, the PushSettingsActivity defined above will be launched.

Note: In some cases application setting screens will require the user to be logged in. Because of this, you may need to add some extra logic to your application to ensure that there is an authenticated user and if not, handling that case accordingly. Whilst the chance of this happening may be slim, it’s a small amount of work to ensure that the user doesn’t end up in a weird state.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s