一、自定义通知Notification:自己定义通知Notification下拉后的显示样式
注意:以下有些方法需要在build.gradle里修改minSdkVersion 21才能使用
只需在构建普通Notification的构建器builder上添加对bigContentView属性设置为RemoteView(自定义的通知样式),如需要对通知展开视图RemoteView里的UI控件设置监听,需要通过设置广播和RemoteView的setOnClickPendingIntent()方法配合使用
Notification notification;
NotificationManager manager;
static Receive receive;
//发送自定义视图的通知
public void sendNotification(){
Notification.Builder builder=new Notification.Builder(this);
builder.setSmallIcon(R.drawable.ic_launcher_background); //设置小图标(未展开上方显示图标)
builder.setTicker("QlynMusic又出新歌了,快来收听吧"); //显示最先在顶部收到的通知
builder.setWhen(System.currentTimeMillis()); //发送时间
builder.setAutoCancel(false);//点击通知后是否取消通知
builder.setWhen(System.currentTimeMillis());//设置通知的时间
//setVisibility用来设置通知在什么情况下会显示
/*
N