Am not able to share PDF using intent only in android 12 but its working fine below version. Am downloading file and taking file Uri from download folder.
Download location:
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS)
Error message: Sharing failed, please try again.
private void sharePDF() {
Uri fileUri = FileProvider.getUriForFile(getApplicationContext(), getPackageName() + ".provider", pdfFile);
Intent share = new Intent();
share.setAction(Intent.ACTION_SEND);
share.putExtra(Intent.EXTRA_STREAM, fileUri);
share.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
share.setType("application/pdf");
startActivity(Intent.createChooser(share, "Share Catalogue"));
}