Android推送通知横幅未显示在某些设备中

roh*_*thi 9 android push-notification

我试图通过以下方式推送通知NotificationCompat:

NotificationCompat.Builder b = new NotificationCompat.Builder(this);
            b.setAutoCancel(true)
                    .setDefaults(NotificationCompat.DEFAULT_ALL)
                    .setWhen(System.currentTimeMillis())
                    .setSmallIcon(this.getResources().
                        getIdentifier("ic_launcher", "mipmap", this.getPackageName()))
                    .setLargeIcon(BitmapFactory.decodeResource(this.getResources(),
                        this.getResources().
                        getIdentifier("ic_launcher", "mipmap", this.getPackageName())))
                    .setTicker("God Reacts")
                    .setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
                    .setPriority(Notification.PRIORITY_MAX)
                    .setContentTitle(data.get("lineOne"))
                    .setContentText(data.get("lineTwo"))
                    .setContentInfo("Spread the message !");

            PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
                    new Intent(this,getMainActivityClass()),
                    PendingIntent.FLAG_UPDATE_CURRENT);
            b.setContentIntent(contentIntent);
            NotificationManager nm = (NotificationManager) 
            this.getSystemService(Context.NOTIFICATION_SERVICE);
            nm.notify(1, b.build());
Run Code Online (Sandbox Code Playgroud)

但在少数设备(三星,MI等)中,未显示通知横幅.通知在动作托盘中滑动并发出声音和振动.

但是在少数设备中,当应用程序关闭/后台/前景时,它会完美显示.正确弹出的设备使用棉花糖.这是由于特定的操作系统?或者是与设备相关的问题?我需要添加多少额外的东西?

roh*_*thi 1

问题出在某些设备的设置上。

Floating notifications需要从设置 -> 应用程序 -> 通知中打开“ ”。