1 .创建一个Note的Activity |
2 . Intent intent= new Intent( this ,Note. class ); |
PendingIntent pi = PendingIntent.getActivity( this , 0 , intent, 0 ); //延迟执行 |
NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); |
Notification notification= new NotificationCompat.Builder( this ) |
.setContentTitle( "通知标题" ) |
.setContentText( "通知正文" ) |
.setWhen(System.currentTimeMillis()) //何时发出通知 |
.setSmallIcon(R.mipmap.ic_launcher) |
.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher)) |
.setContentIntent(pi) |
.setDefaults(NotificationCompat.DEFAULT_ALL) |
// .setStyle(new NotificationCompat.BigPictureStyle().bigPicture(BitmapFactory.decodeResource(getResources(), R.drawable.big_image))) |
.setPriority(NotificationCompat.PRIORITY_MAX) |
.build(); |
manager.notify( 1 , notification); //参数(通知id ,Notification的实例对象) |
3 .点击通知后会跳转到Note的Activity |
by: 发表于:2017-09-26 11:43:27 顶(0) | 踩(0) 回复
??
回复评论