I am trying to create a notification channel with High Priority but the channel created has "sound off" and "floating notification" is off. I am not sure if I should include any special permission to achieve it.
I have tried creating notification channel with high priority. Have tried changing the channel id and reinstalling the app. I am trying it in a complete new application.
// To create channel
private void createNotificatnChennal() {
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
{
NotificationChannel chennal1 = new NotificationChannel(
chennal_01_id,
chennal_01_name,
NotificationManager.IMPORTANCE_HIGH
);
AudioAttributes att = new AudioAttributes.Builder()
.setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
.setUsage(AudioAttributes.USAGE_ALARM)
.build();
chennal1.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION),att);
chennal1.setDescription("Test channel one");
NotificationManager manager = getSystemService(NotificationManager.class);
manager.createNotificationChannel(chennal1);
}
}
// display notification
String title = "Test title";
String body = "Test Msg";
Notification notification = new NotificationCompat.Builder(MainActivity.this,chennal_01_id)
.setSmallIcon(R.drawable.ic_icon)
.setContentText(body)
.setContentTitle(title)
.setPriority(NotificationCompat.PRIORITY_MAX)
.setCategory(NotificationCompat.CATEGORY_MESSAGE)
.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
.setVibrate(new long[0])
.setDefaults(Notification.DEFAULT_ALL)
.build();
notifManager.notify(1,notification);
I want my notification to make sound and popup at the top.
But for now its not making sound and doesn't popup for version >= 8.0, and for < 8.0 its making sound but no popup.