点击我尝试过的通知后,我必须打开pdf文件:
createNotificationChannel();
File file = new File(path);
Uri selectedUri = Uri.parse(file.getAbsolutePath());
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
//intent.setDataAndType(selectedUri, "resource/folder");
intent.setDataAndType(selectedUri, "pdf/*");
//PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 0);
final PendingIntent contentIntent = PendingIntent.getActivity(this, 0,intent, 0);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, "0");
builder.setSmallIcon(R.drawable.ic_notification);
builder.setContentTitle(nomePdf + " creato");
builder.setContentText("Il tuo pdf è stato salvato nella cartella download");
builder.setPriority(NotificationCompat.PRIORITY_DEFAULT);
builder.setAutoCancel(true);
builder.setContentIntent(contentIntent);
NotificationManagerCompat notificationManagerCompat = NotificationManagerCompat.from(this);
notificationManagerCompat.notify(0, builder.build());
它可以工作,但是会打开文件管理器,而不是