欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Notification 悬挂通知

程序员文章站 2024-01-05 10:23:58
...
 mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);

Notification.Builder builder3=new Notification.Builder(this);
          Intent intent3=new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.jianshu.com/p/82e249713f1b"));
          PendingIntent pendingIntent3=PendingIntent.getActivity(this,0,intent3,0);
          builder3.setContentIntent(pendingIntent3);
          builder3.setSmallIcon(R.mipmap.ic_launcher);
          builder3.setLargeIcon(BitmapFactory.decodeResource(getResources(),R.mipmap.ic_launcher));
          builder3.setAutoCancel(true);
          builder3.setContentTitle("悬挂通知");

          Intent XuanIntent=new Intent();
          XuanIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
          XuanIntent.setClass(this,MainActivity.class);

          PendingIntent xuanpengdIntent=PendingIntent.getActivity(this,0,XuanIntent,PendingIntent.FLAG_CANCEL_CURRENT);
          builder3.setFullScreenIntent(xuanpengdIntent,true);
          mNotificationManager.notify(2,builder3.build());

 

上一篇:

下一篇: