1.获取NotificationManager
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
2.获取NotificationCompat.Builder
NotificationCompat.Builder builder=new NotificationCompat.Builder(this);
3.设置基础属性
builder.setContentTitle(title);
builder.setSmallIcon(R.mipmap.ic_launcher);
builder.setLargeIcon(BitmapFactory.decodeResource(getResources(),R.mipmap.ic_launcher));
builder.setContentText(progress+"%");
builder.setProgress(100,progress,false);//设置进度条,参数3:是否模糊进度条
4.设置点击事件
Intent intent=new Intent(this,MainActivity.class);
PendingIntent pi=PendingIntent.getActivity(this,0,intent,0);
builder.setContentIntent(pi);