我正在與facebook,twitter,Linkedin,picasa共享一張照片。我可以分享文本沒有任何problem.Can任何一個有一些例子來說明如何共享一個photo.For的那一刻,我用下面的代碼(添加一個便於分享行動)如何在android中共享一張照片?
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);
}
}
}
在此先感謝
我回答了這樣的問題: http://stackoverflow.com/questions/19700889/share-link-via-intent-from-preferencescreen/19704522#19704522 – user2940520