简体   繁体   中英

How to share picture or text from fragment to Facebook using android studio?

I try to share picture from a fragment in android studio to facebook

..... the application has many of fragments so if i press on "share" the picture in this fragment will share on my Facebook and so on for the rest.

I used Intent to share text but this not work :

Intent intent = new Intent(Intent.ACTION_SEND);
 intent.setType("text/plain");
 intent.putExtra(Intent.EXTRA_TEXT, desc.getText().toString());
 startActivity(Intent.createChooser(intent, "Share with"));
 share(desc.getText().toString());

Thanks

try this reference:

: http://simpledeveloper.com/how-to-share-an-image-on-facebook-in-android/ hope it will help you.if it is working accept my answer

You can try this with the use of 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("FileSharingUrl"));
        builder.setImageUrl(Uri.parse("image url"));
        if (mSharePhotoosUrl) {
            builder.setContentDescription("body description");
        }
        if (mShareCreator) {
            builder.setContentTitle("title if any");
        }
        dialog.show(getActivity(), builder.build());
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM