In Android O, I have the following NotificationChannel
private static String getNotificationChannelId() {
WeNoteApplication weNoteApplication = WeNoteApplication.instance();
final String default_notification_channel_id = weNoteApplication.getString(R.string.default_notification_channel_id);
return default_notification_channel_id;
}
public static String createNotificationChannel() {
final String default_notification_channel_id = getNotificationChannelId();
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
return default_notification_channel_id;
}
WeNoteApplication weNoteApplication = WeNoteApplication.instance();
NotificationManager notificationManager =
(NotificationManager) weNoteApplication.getSystemService(Context.NOTIFICATION_SERVICE);
final String default_notification_channel_name = weNoteApplication.getString(R.string.default_notification_channel_name);
final String default_notification_channel_description = weNoteApplication.getString(R.string.default_notification_channel_description);
NotificationChannel notificationChannel = new NotificationChannel(
default_notification_channel_id,
default_notification_channel_name,
NotificationManager.IMPORTANCE_HIGH
);
notificationChannel.setDescription(default_notification_channel_description);
notificationChannel.enableLights(true);
notificationChannel.enableVibration(true);
notificationManager.createNotificationChannel(notificationChannel);
// How to get the name of sound?
AudioAttributes audioAttributes = notificationChannel.getAudioAttributes();
android.util.Log.i("CHEOK", "toString--> " + audioAttributes.toString());
android.util.Log.i("CHEOK", "getSound--> " + notificationChannel.getSound());
android.util.Log.i("CHEOK", "getDescription--> " + notificationChannel.getDescription());
return default_notification_channel_id;
}
I was wondering, is it possible to get the name of sound from NotificationChannel
, as shown in screenshot?