private void createShareIntent() {
Intent shareIntent = new Intent(Intent.ACTION_SEND);
String file = "/mnt/sdcard/9gag_4155804.jpg";
File f = new File(file);
if (!f.exists()) {
Toast.makeText(getApplicationContext(), "File doesnt exists", Toast.LENGTH_SHORT).show();
return;
} else {
Toast.makeText(getApplicationContext(), "We can go on!!!", Toast.LENGTH_SHORT).show();
}
Uri uri = Uri.fromFile(f);
shareIntent.setType("image/jpeg");
shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(Intent.createChooser(shareIntent, "How do you want to share?"));
}
该文件存在,我没有收到吐司。 当调用这个方法时,很多意图都被聆听。 (Google Drive,Mail,Plus等) 我点击Google Plus,它告诉我“并非所有的媒体文件都可以附加到帖子中”。 使用Google云端硬盘或任何其他服务时会发生同样的情况。 我只是不能分享任何图像...分享意图不适用于图像?
任何想法?
//编辑 我得到烤面包“我们可以继续!!!”
尝试把吐司在'else'和检查... –
添加和我得到的敬酒说:“我们可以继续” –
使用'Environment.getExternalStorageDirectory()',并检查你,你给路径 –