Toast加Notifion
自定义吐司
Nofification 相关类
NotificationManager
方法 notify
Notification.Builder
方法
buider.setSmiicom(R.mipmap.xxx)
buider.setContentTitle(“标题”)
buider.setContentText(正文);
buider.build

Toast toast= new Toast(Main3Activity.this);
View view2=LayoutInflater.from(Main3Activity.this).inflate(R.layout.pop,null);
toast.setView(view2);
toast.setDuration(Toast.LENGTH_LONG);
toast.show();
NotificationManager manager= (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
Notification.Builder builder=new Notification.Builder(Main2Activity.this);
builder.setSmallIcon(R.mipmap.r5);
builder.setContentTitle(“普通”);
builder.setContentText(“只等一个人”);
builder.setContentInfo(“皮卡丘”);
Intent intent=new Intent(Main2Activity.this,MainActivity.class);
PendingIntent pendingIntent=PendingIntent.getActivity(Main2Activity.this,100,intent,PendingIntent.FLAG_ONE_SHOT);
builder.setContentIntent(pendingIntent);
builder.setDefaults(Notification.DEFAULT_ALL);
manager.notify(1,builder.build());
NotificationManager manager= (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
Notification.Builder builder=new Notification.Builder(Main2Activity.this);
builder.setSmallIcon(R.mipmap.r1);
builder.setContentTitle(“我是标题”);
builder.setContentText(“我是内容”);
RemoteViews remoteViews=new RemoteViews(getPackageName(),R.layout.item1);
remoteViews.setTextViewText(R.id.bzu2,“宋定行”);
remoteViews.setImageViewResource(R.id.bzu2,R.drawable.ic_launcher_background);
builder.setContent(remoteViews);
manager.notify(2,builder.build());
NotificationManager manager= (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
Notification.Builder builder = new Notification.Builder(Main2Activity.this);
builder.setSmallIcon(R.mipmap.r5);
builder.setContentTitle(“我是标题”);
builder.setContentText(“我是内容”);
Notification.InboxStyle inboxStyle=new Notification.InboxStyle();
inboxStyle.addLine(“A同学说: 你很飘啊…”);
inboxStyle .addLine(“B同学说: 你是不是以为我拿不到刀…”);
inboxStyle .addLine(“C同学说: 我以为你就是…”);
builder.setStyle(inboxStyle);
manager.notify(3,builder.build());
NotificationManager manager= (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
Notification.Builder builder = new Notification.Builder(Main2Activity.this);
builder.setSmallIcon(R.mipmap.r1);
builder.setContentTitle("我是标题");
builder.setContentText("我是内容");
Notification.BigPictureStyle bigPictureStyle = new Notification.BigPictureStyle();
bigPictureStyle.bigPicture(BitmapFactory.decodeResource(getResources(),R.mipmap.z1));
builder.setStyle(bigPictureStyle);
manager.notify(4,builder.build());
NotificationManager manager= (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
final Notification.Builder builder = new Notification.Builder(Main2Activity.this);
builder.setSmallIcon(R.mipmap.ic_launcher);
builder.setContentTitle("我是标题");
final Timer timer=new Timer();
timer.schedule(new TimerTask() {
int progress;
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
@Override
public void run() {
builder.setContentText("正在下载,当前进度"+progress);
builder.setProgress(100,progress,false);
progress+=10;
manager.notify(6,builder.build());
if(progress==100){
//2.安装过程
builder.setContentText("正在安装");
builder.setProgress(0,0,true);
manager.notify(6,builder.build());
try {
Thread.sleep(7000);
} catch (InterruptedException e) {
e.printStackTrace();
}
manager.cancel(6);
timer.cancel();
//handler.sendEmptyMessage(12);
}
}
}, 0, 1000);