1. Are you ready for the Galaxy S20? Here is everything we know so far!

NotificationChannel on Xiaomi Redmi 5 plus Android 8.1.0

Discussion in 'Android Development' started by eldona, Nov 16, 2018.

  1. eldona

    eldona Lurker
    Thread Starter

    I create a notification channel with NotificationManager.IMPORTANCE_HIGH:

    Code (Java):
    1. NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    2. String CHANNEL_ID_CALL = "call";
    3. NotificationChannel mChannel = new NotificationChannel(CHANNEL_ID_CALL, context.getResources().getString(R.string.notification_call_channel_name), NotificationManager.IMPORTANCE_HIGH);
    4. mChannel.setDescription(context.getResources().getString(R.string.notification_call_channel_description));
    5. Uri notificationSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
    6. AudioAttributes attributes = new AudioAttributes.Builder().setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
    7.         .setLegacyStreamType(AudioManager.STREAM_RING)
    8.         .setUsage(AudioAttributes.USAGE_NOTIFICATION_RINGTONE).build();
    9. mChannel.setSound(notificationSound, attributes);
    10. mChannel.setVibrationPattern(new long[]{0, 700, 500, 700});
    11. mChannel.enableVibration(true);
    12. mChannel.enableLights(true);
    13.  
    14. mNotificationManager.createNotificationChannel(mChannel);
    When i check notification channel created on device, the channel is created successfully, but when I open Notification setting from app settings, the notification sound is disabled.

    In other devices the notification channel is correctly created and sound is enabled.

    Someone know how solve this problem?

    Thanks
     


Loading...

Share This Page

Loading...