普通通知
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
Notification.Builder builder = new Notification.Builder(Main2Activity.this);
builder.setSmallIcon(R.mipmap.ic_launcher);
builder.setContentTitle("我是标题");
builder.setContentText("我是文本");
builder.setDefaults(Notification.DEFAULT_ALL);
builder.setWhen(System.currentTimeMillis());
Notification build = builder.build();
manager.notify(1,build);
}
});
自定义通知
public