notification

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/SKYYYF/article/details/71641366

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

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);


猜你喜欢

转载自blog.csdn.net/SKYYYF/article/details/71641366