Reputation: 34
I want to share text/image or link on Facebook using intent and i want share only on Facebook.
share intent for mail working properly but not Facebook. please help
Intent intent = new Intent(Intent.ACTION_SENDTO);
intent.setData(Uri.parse("mailto:")); // only email apps
// should handle
// this
intent.putExtra(Intent.EXTRA_TEXT, AppLink);
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent);
}
Upvotes: 1
Views: 913
Reputation: 2959
Use facebook Sdk.
private void shareFacebook(){
if (!ShareDialog.canShow(ShareLinkContent.class)) return;
ShareDialog dialog = new ShareDialog(this);
ShareLinkContent.Builder builder = new ShareLinkContent.Builder();
builder.setContentUrl(Uri.parse("file sharing url"));
builder.setImageUrl(Uri.parse("image url));
builder.setContentDescription("http://something.com");
builder.setContentTitle("title / info");
dialog.show(getActivity(), builder.build());
}else {
Toast.makeText(getContext(), R.string.please_wait, Toast.LENGTH_LONG).show();
}
Don't forget to initialize facebook sdk on your activity / fragment.
Hope it help you.
Upvotes: 0
Reputation: 2356
Facebook does not allow to share a link uing intent , you have to use Facebook sdk to do this visit This link
Upvotes: 1