我試圖推動與NotificationCompat
通知:Android的推送通知的旗幟沒有出現在某些設備
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());
但在少數設備(三星,MI等)的通知旗幟不顯示。 通知在聲音和振動的動作托盤中滑動。
但是在很少的設備中,當應用程序關閉/背景/前景時,它顯示得很完美。正確彈出的設備使用棉花糖。是由於特定的操作系統?或者它是與設備相關的問題?我需要額外增加什麼?
只是在某些特殊情況下,某些設備可能會安裝通知清理應用程序,它們可以清理您的通知。我之前遇到過這個問題,這完全讓我發瘋。也許你可以檢查它。 –
@ Spark.Bao我不認爲是這種情況。我在2個真實設備上檢查了它,沒有通知清理應用程序。我不明白這些問題發生的原因 –
您是否檢查過這個:https:// stackoverflow .com/questions/29522254/get-android-notification-to-appear-as-banner? – josealfonsomora