I want to share Image and text using andoroid share intent. In Existing Code, It share "null.bin" file for whatsapp and for gmail "couldn't attach file" error.
String msg = title + "\n\nDownload the app now & Register using link:\n "+ invitationLink;
Uri imageUri = (new Uri.Builder())
.scheme(ContentResolver.SCHEME_ANDROID_RESOURCE)
.authority(getContext().getResources().getResourcePackageName(R.drawable.hblogo))
.appendPath(getContext().getResources().getResourceTypeName(R.drawable.hblogo))
.appendPath(getContext().getResources().getResourceEntryName(R.drawable.hblogo))
.build();
//Share Android App Data To Other Apps
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
//Image Uri Share
if(imageUri!=null){
sendIntent.putExtra(Intent.EXTRA_STREAM, imageUri);
}
sendIntent.putExtra(Intent.EXTRA_TEXT, msg);
sendIntent.setType("*/*");
Intent shareIntent = Intent.createChooser(sendIntent, null);
startActivity(shareIntent);
}