我尝试了推送通知,它在android果冻豆工作良好,但相同的代码不工作棉花糖和棒棒糖。
设备获取其他应用程序通知,如WhatsApp、Gmail..也不能说设置有问题。
谷歌它一些图标改变了新版本,但我也没有得到通知,谢谢各位:)
我的通知代码:
NotificationIntent = new Intent(this, Activity.class);
NotificationIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
NotificationPendingIntent = PendingIntent.getActivity(this, 0, NotificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationBuilder = new Notification.Builder(this)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle("GREEK NEWS")
.setContentText(content)
.setDefaults(Notification.DEFAULT_ALL)
.setAutoCancel(true)
.setContentIntent(NotificationPendingIntent);
NotificationManager = (android.app.NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
NotificationManager.notify(86, NotificationBuilder.build());
} else {
NotificationManager.notify(86, NotificationBuilder.getNotification());
}
最佳答案
尝试更改nofication图标
.setSmallIcon(getNotificationIcon())
创造方法
private int getNotificationIcon() {
boolean useWhiteIcon = (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP);
return useWhiteIcon ? R.drawable.notification_icon : R.mipmap.ic_launcher;
}
希望。它帮助你!!!!