notification

来源:互联网 发布:裴健 数据挖掘 编辑:程序博客网 时间:2024/06/08 06:21

点击按钮后执行下面的代码

Notification.Builder builder=new Notification.Builder(this);Intent intent=new Intent(this,SecondActivity.class);PendingIntent pendingIntent = PendingIntent.getActivity(this,0,intent,PendingIntent.FLAG_UPDATE_CURRENT);builder.setContentIntent(pendingIntent);builder.setSmallIcon(R.mipmap.ic_launcher)       .setTicker("状态栏标题")       .setContentTitle("标题")       .setContentText("内容");       //API16以下用getNotification(),16及其以上用build()方法       Notification notification=builder.getNotification();notificationManager.notify(0,notification);


0 0
原创粉丝点击