My code is working fine without image to send but when I am send data with image it shows error. If you are giving me some url there answer has been posted before so make sure that answer is correct because I tried lots of answer on stackoverflow.
Here is my code.
Uri contentUri = Uri.parse("android.resource://" + BuildConfig.APPLICATION_ID + "/drawable/" + "ic_launcher");
if (contentUri != null) {
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
// shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); // temp permission for receiving app to read this file
shareIntent.setType("text/plain");
shareIntent.setType("image/*");
shareIntent.putExtra(Intent.EXTRA_TEXT, "MY messgae");
shareIntent.putExtra(Intent.EXTRA_STREAM, contentUri);
try {
startActivity(Intent.createChooser(shareIntent, "Share via"));
} catch (ActivityNotFoundException e) {
Toast.makeText(getContext(), "No App Available", Toast.LENGTH_SHORT).show();
}
}
It showing error that is sendind data failed try again later I am unable to getting my error.