android设置通知在屏幕横幅显示,Android推送通知横幅未显示在某些设备中
我試圖用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());但是在少數(shù)設(shè)備(三星,MI等)中沒(méi)有顯示通知橫幅。
通知在聲音和振動(dòng)下滑動(dòng)到動(dòng)作托盤中。
但是在少數(shù)設(shè)備中,當(dāng)應(yīng)用程序關(guān)閉/背景/前景時(shí),它顯示得很完美。正確彈出的設(shè)備使用棉花糖。這是由于特定的操作系統(tǒng)?或者它是與設(shè)備相關(guān)的問(wèn)題?我需要額外增加什么?
總結(jié)
以上是生活随笔為你收集整理的android设置通知在屏幕横幅显示,Android推送通知横幅未显示在某些设备中的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: android xml 删除控件,and
- 下一篇: android textview 文字居