I am trying to set up social sharing. It is working fine by showing all the available options when I select to share. But is there anyway I can check if the user selected 'Facebook' as their method of sharing cos I want to fire the relevant facebok sdk related codes when that happens. It seems facebook has limitation on what can be posted if I do not take their SDK route unlike other share options.
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if(id == R.id.social_share){
//working - this opens up available sharing options on device.
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("text/plain");
i.putExtra(android.content.Intent.EXTRA_SUBJECT, "A Title");
i.putExtra(Intent.EXTRA_TEXT, "This is content... ");
startActivity(i.createChooser(i, "Share"));
//I want to use this code if facebook is selected.
if (ShareDialog.canShow(ShareLinkContent.class)) {
ShareLinkContent linkContent = new ShareLinkContent.Builder()
.setContentTitle("Hello Facebook")
.setContentDescription(
"The 'Hello Facebook' sample showcases simple Facebook integration")
.setContentUrl(Uri.parse("http://developers.facebook.com/android"))
.build();
.setImageUrl(Uri.parse("http://....."))
shareDialog.show(linkContent);
}
}
return true;
}