Access application notification settings programmatically [duplicate]
Asked Answered
B

3

26

In an Android app, I have a button that I want to have the functionality of opening the App Notification settings (in Android settings).

Screenshot of Android's notification settings for the Camera application

I can open the Android settings with this

startActivityForResult(new Intent(android.provider.Settings.ACTION_SETTINGS), 0);

but I want to open directly on my app notification settings

Alternative

If there is a way to turn the "Block notifications" on and off programmatically that would be ok too.

Baluchi answered 30/6, 2016 at 13:27 Comment(1)
Add a boolean, save it and add settings inside the app.Belen
D
17

There is no public API that will allow you to deep link into your application's notification settings directly.

You can use Settings.ACTION_APPLICATION_DETAILS_SETTINGS to deep link to your application's settings, but this will not take you directly to the notifications screen.

Any way to link to the Android notification settings for my app? has a solution that may work, but since it is not a part of the official API it is not guaranteed to work on all devices or for future versions of Android.

if there is a way to turn the "Block notificaations" on and off programatically that would be ok too

Absolutely not. Allowing an application to programmatically turn it's notifications on and off defeats the purpose of giving the user control over turning notifications on and off.

Dab answered 30/6, 2016 at 13:42 Comment(2)
ill use the Settings.ACTION_APPLICATION_DETAILS_SETTINGS then, thanksBaluchi
I am using APP_NOTIFICATION_SETTINGS to open setting ,how to open sub category?Victim
K
67

I know this is an old question, but for those finding it in the future: as of Oreo (API level 26) there is now an official deeplink Intent for a specific app's notification settings.

Intent settingsIntent = new Intent(Settings.ACTION_APP_NOTIFICATION_SETTINGS)
        .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
        .putExtra(Settings.EXTRA_APP_PACKAGE, getPackageName())
        .putExtra(Settings.EXTRA_CHANNEL_ID, MY_CHANNEL_ID);
startActivity(settingsIntent);

The EXTRA_CHANNEL_ID parameter is optional, and according to the docs, will "highlight that channel." FWIW, as of Android 8.1, I can't see that it makes any difference. If you are adding this parameter, ensure your Action is ACTION_CHANNEL_NOTIFICATION_SETTINGS.

Kirbie answered 15/2, 2018 at 21:16 Comment(3)
how to open app notification category (Default) ? on orio. where we can change sound,vibration and other setting.Victim
In order to open settings of a particular channel use new Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS)Compressor
@DmitryGrushin Oh man, You just saved my life, the settings app would crash if I provide a EXTRA_CHANNEL_ID extra with ACTION_APP_NOTIFICATION_SETTINGS action.Formyl
D
17

There is no public API that will allow you to deep link into your application's notification settings directly.

You can use Settings.ACTION_APPLICATION_DETAILS_SETTINGS to deep link to your application's settings, but this will not take you directly to the notifications screen.

Any way to link to the Android notification settings for my app? has a solution that may work, but since it is not a part of the official API it is not guaranteed to work on all devices or for future versions of Android.

if there is a way to turn the "Block notificaations" on and off programatically that would be ok too

Absolutely not. Allowing an application to programmatically turn it's notifications on and off defeats the purpose of giving the user control over turning notifications on and off.

Dab answered 30/6, 2016 at 13:42 Comment(2)
ill use the Settings.ACTION_APPLICATION_DETAILS_SETTINGS then, thanksBaluchi
I am using APP_NOTIFICATION_SETTINGS to open setting ,how to open sub category?Victim
E
0
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Uri uri = Uri.fromParts("package", getPackageName(), null);
intent.setData(uri);
startActivity(intent);
Engen answered 25/11, 2017 at 5:14 Comment(2)
how to open app notification category (Default) ? on orio. where we can change sound,vibration and other settingVictim
Intent settingsIntent = new Intent(Settings.ACTION_APP_NOTIFICATION_SETTINGS) .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) .putExtra(Settings.EXTRA_APP_PACKAGE, getPackageName()) .putExtra(Settings.EXTRA_CHANNEL_ID, "channel_id"); startActivity(settingsIntent);Engen

© 2022 - 2025 — McMap. All rights reserved.