Intent intent = new Intent(context, XXActivity.class);intent.putExtra("recFile", recName);PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);Notification.Builder builder = new Notification.Builder(context);builder.setTicker("新的通知");builder.setSmallIcon(R.drawable.ic_launcher);builder.setContentTitle("收到新的通知");builder.setContentText("您有一条新的通知");builder.setContentIntent(pendingIntent);Notification notification = builder.build();notification.flags = Notification.FLAG_AUTO_CANCEL;manager.notify(NOTIFACTION_FLAG_CODE, notification);
String recFileName = getIntent().getStringExtra("recFile");if (recFileName != null) {//处理逻辑...}
原文:http://www.cnblogs.com/yuzhongzheng/p/5412585.html