android 通知栏 notifcation

  http://blog.csdn.net/guolin_blog/article/details/50945228  郭神的博客

final NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
final Notification notification = builder.setContentTitle("这是通知标题").setContentText("这是通知的内容").
setWhen(System.currentTimeMillis()).setSmallIcon(R.mipmap.ic_launcher).setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher))
.setColor(Color.parseColor("#EAA935")).build();


final Notification notification2 = builder.setContentTitle("这是通知标题2").setContentText("这是通知的内容2").
setWhen(System.currentTimeMillis()).setSmallIcon(R.mipmap.ic_launcher).setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher))
.build();


btn_notification = (Button) findViewById(R.id.btn_notification);
btn_notification2 = (Button) findViewById(R.id.btn2);

btn_notification.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
manager.notify(1, notification);
}
});

btn_notification2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
manager.notify(2, notification2);
}
});
原文地址:https://www.cnblogs.com/jeno-song/p/5542304.html