Notifications only appear on some devices

0
Hello, I have a problem I have a function that sends notifications to the user but when I test on the device of Xiaomi mi a1 they are not displayed but other applications present in the no problems, since if I test on a Samsung device it works normally ! Can someone help me?

Function code:

                    public void gerarNotificacao(Context context, Intent intent, CharSequence ticker, CharSequence titulo, CharSequence descricao){
                    NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
                    PendingIntent p = PendingIntent.getActivity(context, 0, intent, 0);

                    NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
                    builder.setTicker(ticker);
                    builder.setContentTitle(titulo);
                    builder.setContentText(descricao);
                    builder.setSmallIcon(R.drawable.ic_launcher_background);
                    builder.setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_launcher_background));
                    builder.setContentIntent(p);

                    Notification n = builder.build();
                    n.vibrate = new long[]{150, 300, 150, 600};
                    n.flags = Notification.FLAG_AUTO_CANCEL;
                    nm.notify(R.drawable.ic_launcher_background, n);

                    try{
                        Uri som = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
                        Ringtone toque = RingtoneManager.getRingtone(context, som);
                        toque.play();
                    }
                    catch(Exception e){}
                }
    
asked by anonymous 22.08.2018 / 23:16

0 answers