问题
为什么使用Android Studio开发状态栏消息通知notification但奇怪的是通知不显示?
final NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
PendingIntent pendingIntent = PendingIntent.getActivity(BaiDuMapActivity.this, 0, new Intent().setAction(Intent.ACTION_VIEW), 0);
Notification notify= new Notification.Builder(BaiDuMapActivity.this)
.setTicker( "您有新短消息,请注意查收!")
.setContentTitle("Notification Title")
.setContentText("This is the notification message")
.setContentIntent(pendingIntent).setNumber(1).getNotification();
notify.flags |= Notification.FLAG_AUTO_CANCEL; // FL
manager.notify(1,notify);
解答
查看上面代码发现是没有设置 icon引起的。
.setSmallIcon(R.drawable.icono)