I really need your help. Currently, I am working on notification module in my app. My problem is that notification works under Oreo, but not working on Oreo and Pie. I am using mi (Xiaomi) devices and below is my code:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel channel = notificationManager.getNotificationChannel(CHANNEL_ID);
if (channel == null){
channel = new NotificationChannel(CHANNEL_ID, CHANNEL_NAME, NotificationManager.IMPORTANCE_HIGH);
channel.enableLights(true);
channel.enableVibration(true);
channel.setVibrationPattern(new long[]{100, 200, 300, 400, 500, 400, 300, 200, 400});
channel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
AudioAttributes att = new AudioAttributes.Builder()
.setUsage(AudioAttributes.USAGE_NOTIFICATION)
.setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
.build();
channel.setSound(Uri.parse(sound), att);
notificationManager.createNotificationChannel(channel);
}
mBuilder = new NotificationCompat.Builder(mContext, CHANNEL_ID);
mBuilder.setSmallIcon(icon)
.setTicker(message)
.setWhen(System.currentTimeMillis())
.setAutoCancel(true)
.setContentTitle(title)
.setContentIntent(resultPendingIntent)
.setSound(Uri.parse(sound))
.setLights(0xff00ff00, 500, 500)
.setStyle(new NotificationCompat.BigTextStyle()
.bigText(notificationVO.getMessage()))
.setLargeIcon(BitmapFactory.decodeResource(mContext.getResources(), icon))
.setContentText(message)
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
.setVibrate(new long[]{100, 200, 300, 400, 500, 400, 300, 200, 400});
}
The detail of my problem is that notification is receiving by phone when the condition is turned on but no sound, vibration. in lock screen the notification not showing, no led, no vibration, and no sound.
Is there anyone who know how to solve this? Thank you all and I am really appreciate your help