我想使用 android 共享意图共享图像和文本。在现有代码中,它为 whatsapp 和 gmail 共享“null.bin”文件“无法附加文件”错误。
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);
}