Android共享意图不加载图像
当我尝试使用intent在facebook上共享图像时,收到消息“抱歉,我们无法加载您的照片” 我正在使用以下代码Android共享意图不加载图像,android,android-intent,Android,Android Intent,当我尝试使用intent在facebook上共享图像时,收到消息“抱歉,我们无法加载您的照片” 我正在使用以下代码 Uri imageUri = Uri.parse("android.resource://"+getPackageName()+"/drawable/"+filename); Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("image/jpg");
Uri imageUri = Uri.parse("android.resource://"+getPackageName()+"/drawable/"+filename);
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("image/jpg");
intent.putExtra(Intent.EXTRA_STREAM, imageUri);
startActivity(Intent.createChooser(intent , "Share"));
当我试图通过gmail发送邮件时,没有收到任何附件。
我可以知道原因吗?某些应用程序(如Gmail、Facebook、Google Plus…)无法获取照片以附加,因为您的imageUri是私有的
public void shareImage()
{
Bitmap icon = mBitmap;
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("image/jpeg");
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
icon.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
File f = new File(Environment.getExternalStorageDirectory() + File.separator + "temporary_file.jpg");
try {
f.createNewFile();
FileOutputStream fo = new FileOutputStream(f);
fo.write(bytes.toByteArray());
} catch (IOException e) {
e.printStackTrace();
}
share.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/temporary_file.jpg"));
startActivity(Intent.createChooser(share, "Share Image"));
}
您应该将drawable保存到gallery或公用文件夹,然后获取newImageUri进行共享。
intent.putExtra(intent.EXTRA_流,newImageUri)代码>是的,我明白这一点,并以同样的方式做了。谢谢