文件下载成功 通知 然后点击 跳转到对应页面

intrequestCode = (int) System.currentTimeMillis();

Bitmap btm= BitmapFactory.decodeResource(getResources(), R.drawable.ic_menu_compose);

NotificationCompat.Builder mBuilder=newNotificationCompat.Builder(getApplication()).setSmallIcon(R.mipmap.ic_launcher)

.setContentTitle("文件下载成功").setContentText(fileName+"");

mBuilder.setTicker("新的消息");

//mBuilder.setNumber(12);

mBuilder.setLargeIcon(btm);

mBuilder.setAutoCancel(true);

mBuilder.setPriority(Notification.PRIORITY_MAX);

mBuilder.setDefaults(Notification.DEFAULT_ALL);

mBuilder.setOnlyAlertOnce(true);

//构建一个intent

Intent resultIntent =newIntent();

resultIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

//设置intent的Action属性

resultIntent.setAction(Intent.ACTION_VIEW);

// Intent resultIntent=new Intent(getApplicationContext(), PushNewsActivity.class);

String type = Helper.getMIMEType(file);

//设置intent的data和Type属性。

resultIntent.setDataAndType(/*uri*/Uri.fromFile(file), type);//    public Intent setDataAndType(Uri data, String type)

PendingIntent resultPI=PendingIntent.getActivity(getApplication(),requestCode,resultIntent,PendingIntent.FLAG_CANCEL_CURRENT);

mBuilder.setContentIntent(resultPI);

NotificationManager mNotif= (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

mNotif.notify(requestCode,mBuilder.build());

你可能感兴趣的:(文件下载成功 通知 然后点击 跳转到对应页面)