Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
282 views
in Technique[技术] by (71.8m points)

Sharing images and text with Facebook on Android

Facebook, why you no take images and text in share Intent?

enter image description here

I'm trying to use the standard Android share Intent to share an image, and some text. My share Intent is set up right, I've got the image in there, and I've done my end of the deal. My code, let me show you it:

public void doShare() {
    File image = getShareFile();
    Intent shareIntent = new Intent();
    shareIntent.setAction(Intent.ACTION_SEND);
    shareIntent.setType("*/*");
    shareIntent.putExtra(Intent.EXTRA_SUBJECT, resultObject.getShareSubject());
    shareIntent.putExtra(Intent.EXTRA_TEXT, resultObject.getShareText());
    shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(image));
    shareActionProvider.setShareIntent(shareIntent);
}

Facebook shows up in the list of apps that will handle my Intent, but it lies!!! When clicking on Facebook to actual do a share it says:

Please attach only photos or a single video.

Why Facebook, why? Why do you show up as an app that can handle my Intent, then make me look stupid to my users by not handling the Intent? You promised Facebook.

I've seen many many threads on this all over this site, and the web. Has anyone gotten this to work without having to use their API?

question from:https://stackoverflow.com/questions/14244998/sharing-images-and-text-with-facebook-on-android

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Why? Because they are Facebook and can permit to themselves such bugs. So, they expect only images upon type is "image/". If the type is "text/plain"-then a URL should be contained in the message. Don't use .setType("/*"); Otherwise use their SDK. But in this case you'll sacrifice simplicity and flexibility of your application.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...