我正在尝试在缓存目录中共享图像文件,我有完整的路径,但无法在附件中发送文件,代码是
File shareImage=Utils.getBitmapFile();
Log.d("Activity", "get final path in result"+shareImage.getAbsolutePath());
/*MimeTypeMap mime = MimeTypeMap.getSingleton();
String ext=shareImage.getName().substring(shareImage.getName().lastIndexOf(".")+1);
String type = mime.getMimeTypeFromExtension(ext);
shareIntent.setType(type);
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("image/*");
Uri shareImageUri = Uri.fromFile(shareImage);
Uri shareImageUri = Uri.fromParts("content", shareImage.getAbsolutePath(), null);//("content://"+shareImage.getAbsolutePath());
*/
Uri shareImageUri = Uri.fromFile(shareImage);
Log.d("Result ","uri is "+shareImageUri.toString());
shareIntent.putExtra(Intent.EXTRA_STREAM, shareImageUri);
startActivity(Intent.createChooser(shareIntent, "Share Results"));
上面注释的代码不起作用
发送邮件显示附件,但接收端没有附件,facebook分享也显示没有图片
这是什么原因?
我已经看到以下 SO Links how-to-use-share-image-using-sharing-intent-to-share-images-in-android和许多其他的,他们都无法解决这个问题
附言;
1.目的是将屏幕截图保存在缓存目录中并从那里在线共享
2.是的,我确实有文件,我可以通过 DDMS 从设备中提取它并在系统上查看。