I am using this code to share the image on Whatsapp, Facebook, and Instagram etc.
This code works fine below API 25 but Not Working above API 25.
Intent share = new Intent("android.intent.action.SEND");
share.setType("image/jpeg");
share.putExtra("android.intent.extra.STREAM", Uri.parse(this.imgUrl));
startActivity(Intent.createChooser(share, "via"));
4
Answers
First make sure you have added permission
Then use this code
If targetSdkVersion is higher than 24, then Provider is used to grant access.
Create an xml file : resxmlprovider_paths.xml
now Add a Provider in AndroidManifest.xml file
and replace this with your code
Update
Try this:
follow these steps carefully.. android.os.FileUriExposedException: file:///storage/emulated/0/test.txt exposed beyond app through Intent.getData() This update has been done since nougat..