Ajay S
Ajay S

Reputation: 48592

Text Caption not shared on facebook

I want to share photo with caption but text caption is not shared on Facebook Is there any way to share a text with photo on Facebook using send intent.

List<Intent> targetedShareIntents = new ArrayList<Intent>();
Intent share = new Intent(android.content.Intent.ACTION_SEND);
share.setType("image/jpeg");
List<ResolveInfo> resInfo = getPackageManager().queryIntentActivities(share, 0);
if (!resInfo.isEmpty()){
    for (ResolveInfo info : resInfo) {
        Intent targetedShare = new Intent(android.content.Intent.ACTION_SEND);
        targetedShare.setType("image/jpeg"); // put here your mime type
        if (info.activityInfo.packageName.toLowerCase().contains(nameApp) || info.activityInfo.name.toLowerCase().contains(nameApp)) {
            targetedShare.putExtra(Intent.EXTRA_SUBJECT, "Virtual Mirror Photo");
            targetedShare.putExtra(Intent.EXTRA_TEXT,"This photo is created by Virtual Mirror App.\n\nInfoshore Team");
            targetedShare.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(imagePath)) );
            targetedShare.setPackage(info.activityInfo.packageName);
            targetedShareIntents.add(targetedShare);
            isAppAvaiable = true;
        }
    }
    Intent chooserIntent = Intent.createChooser(targetedShareIntents.remove(0), "Select app to share");
    chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, targetedShareIntents.toArray(new Parcelable[]{}));
    startActivity(chooserIntent);

Upvotes: 2

Views: 2005

Answers (1)

Siddharth Lele
Siddharth Lele

Reputation: 27748

As per the Facebook's Platform Policies, you cannot pre-fill the share dialog using Intent.EXTRA_TEXT. It is usually thought to be a bug, but as per a Bug Report filed here and also, here, Facebook clearly mentions that this is not the case (it's not a bug).

You can read more about their Platform Policies specifically, Platform Policy IV.2

Quote from Platform Policy IV.2:

You must not pre-fill any of the fields associated with the following products, unless the user manually generated the content earlier in the workflow: Stream stories (user_message parameter for Facebook.streamPublish and FB.Connect.streamPublish, and message parameter for stream.publish), Photos (caption), Videos (description), Notes (title and content), Links (comment), and Jabber/XMPP.

These fields are intended for users to express themselves. Pre-filling these fields erodes the authenticity of the user voice.

The bottom line is (unfortunately), you cannot add a caption to a photo you are uploading using Intents. The only way you can do it, is integrating the Facebook SDK in your App. To see an example of how they do it in their sample app Hackbook, refer to this link and scroll down to line 263 where they deal with uploading a Photo with a Caption.

Upvotes: 5

Related Questions