我正在向 facebook、twitter、Linkedin、picasa 分享一张照片。我可以毫无问题地分享文本。任何人都可以用一些例子来解释如何分享一张照片。目前我正在使用以下代码(添加一个简单的分享操作)
private ShareActionProvider mShareActionProvider;
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate menu resource file.
getMenuInflater().inflate(R.menu.main, menu);
MenuItem item = menu.findItem(R.id.menu_item_share);
mShareActionProvider = (ShareActionProvider) item.getActionProvider();
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
//Uri screenshotUri = Uri.fromFile(new File(getFilesDir(), ".jpg"));
Log.d("Storage dir ", "Getting the directory");
File f = FileUtils.getStorageDir();
Log.d("All Answers: ", f.getAbsolutePath());
sharingIntent.setType("image/png");
sharingIntent.putExtra(Intent.EXTRA_STREAM,f);
startActivity(Intent.createChooser(sharingIntent, "Share image using"));
// Set the share Intent
mShareActionProvider.setShareIntent(sharingIntent);
return true;
}
// Call to update the share intent
private void setShareIntent(Intent shareIntent) {
if (mShareActionProvider != null) {
mShareActionProvider.setShareIntent(shareIntent);
}
}
}
提前致谢