Notification 悬挂通知

 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());
发布了180 篇原创文章 · 获赞 27 · 访问量 15万+

猜你喜欢

转载自blog.csdn.net/sinat_28238111/article/details/90057053