我需要发送哪些意图来打开我以前在我的应用中创建的通知频道的设置? 我需要它来链接我的设置活动。
答案 0 :(得分:17)
要打开单个频道的设置,您可以使用ACTION_CHANNEL_NOTIFICATION_SETTINGS
:
Intent intent = new Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS)
.putExtra(Settings.EXTRA_APP_PACKAGE, context.getPackageName())
.putExtra(Settings.EXTRA_CHANNEL_ID, yourChannelId);
startActivity(intent);
使用ACTION_APP_NOTIFICATION_SETTINGS
会列出该应用的所有频道:
Intent intent = new Intent(Settings.ACTION_APP_NOTIFICATION_SETTINGS)
.putExtra(Settings.EXTRA_APP_PACKAGE, context.getPackageName());
startActivity(intent);
答案 1 :(得分:3)
Kotlin代码,支持比Android O 更低的版本以及 Lollipop 的小写字母:
sort
答案 2 :(得分:2)
以下是通知设置和粒度通道设置的摘要:
private void openNotificationSettings() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
Intent intent = new Intent(Settings.ACTION_APP_NOTIFICATION_SETTINGS);
intent.putExtra(Settings.EXTRA_APP_PACKAGE, getPackageName());
startActivity(intent);
} else {
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
intent.setData(Uri.parse("package:" + getPackageName()));
startActivity(intent);
}
}
@RequiresApi(26)
private void openChannelSettings(String channelId) {
Intent intent = new Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS);
intent.putExtra(Settings.EXTRA_APP_PACKAGE, getPackageName());
intent.putExtra(Settings.EXTRA_CHANNEL_ID, channelId);
startActivity(intent);
}