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?"));
}
该文件存在,我没有收到 Toast。调用此方法时,许多意图都是列表。(Google Drive、Mail、Plus 等)我点击 Google Plus,它告诉我“并非所有媒体文件都可以附加到帖子中”。使用 Google Drive 或任何其他服务时也会发生同样的情况。我只是无法分享任何图像...
有任何想法吗?
// 编辑我得到 Toast "We can go on!!!"