Force use of system settings to configure notifications on SDK30+.

This commit is contained in:
Cody Henthorne
2022-05-10 14:47:59 -04:00
committed by Alex Hart
parent 68ba3433a3
commit 06a49b5d5a
7 changed files with 116 additions and 79 deletions

View File

@@ -233,7 +233,7 @@ public class NotificationChannels {
/**
* Navigates the user to the system settings for the desired notification channel.
*/
public static void openChannelSettings(@NonNull Context context, @NonNull String channelId) {
public static void openChannelSettings(@NonNull Context context, @NonNull String channelId, @Nullable String conversationId) {
if (!supported()) {
return;
}
@@ -242,6 +242,9 @@ public class NotificationChannels {
Intent intent = new Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS);
intent.putExtra(Settings.EXTRA_CHANNEL_ID, channelId);
intent.putExtra(Settings.EXTRA_APP_PACKAGE, context.getPackageName());
if (conversationId != null && Build.VERSION.SDK_INT >= CONVERSATION_SUPPORT_VERSION) {
intent.putExtra(Settings.EXTRA_CONVERSATION_ID, conversationId);
}
context.startActivity(intent);
} catch (ActivityNotFoundException e) {
Log.w(TAG, "Channel settings activity not found", e);