经过多次搜索,我找到了以下方式,您可以从中获取所有详细信息。
以下链接显示了如何以编程方式打开您的应用程序通知通道设置。
打开应用通知设置
这可能会帮助某人。
以下代码将返回您申请的所有渠道
public static List<NotificationChannel> getNotificationChannels(Context context) {
if (isNotificationChannelSupported(context)) {
NotificationManager notificationManager =
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
if (notificationManager == null) {
Log.e("", "Notification manager is null");
return null;
}
return notificationManager.getNotificationChannels();
}
return null;
}
public static boolean isNotificationChannelSupported(Context context) {
return Build.VERSION.SDK_INT >= 26 && getTargetSdkVersion(context) >= 26;
}
private static int getTargetSdkVersion(Context context) {
int targetSdk = -1;
if (context != null) {
targetSdk = context.getApplicationInfo().targetSdkVersion;
}
return targetSdk;
}
以下行将以相同的方式返回您的声音Uri
,您可以获得名称、ID 等。
get(2)
是您想要参考的频道检索详细信息,您也可以使用 0,1
Uri soundUri= getNotificationChannels(this).get(2).getSound()