Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 807
Alex.F Avatar asked Feb 24 '15 11:02

Alex.F


People also ask

How do I add an app to the Notification Center in Windows 10?

Go to Settings > System > Notifications & actions‌ , under Get notifications from these senders select the app, and then under Priority of notifications in action center select Top.

How do I start an activity from notifications?

Build and issue the notification: Create an Intent that starts the Activity . Set the Activity to start in a new, empty task by calling setFlags() with the flags FLAG_ACTIVITY_NEW_TASK and FLAG_ACTIVITY_CLEAR_TASK . Create a PendingIntent by calling getActivity() .

How do I change notification settings on Samsung?

Navigate to and open Settings, and then tap Notifications. Tap Advanced settings. Tap Show notification icons, and then adjust your desired settings. For example, you can choose to show all notifications, your three most recent notifications, or so on.


1 Answers

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

like image 158
adneal Avatar answered Oct 09 '22 16:10

adneal