在Android上分享图片和文字与Facebook [英] Sharing images and text with Facebook on Android

查看:1138
本文介绍了在Android上分享图片和文字与Facebook的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Facebook的,你为什么不拍摄图像和文字的份额意图是什么?

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

我想使用标准的Andr​​oid份额意图共享图像,和一些文字。我占有率的目的是树立正确的,我已经得到了图像在那里,我已经做好了应对的我的结束。我的code,让我告诉你吧:

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的显示在应用程序将要处理我的意图的列表,但它位于!当点击Facebook上实际做一个分享它说:

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.

为什么Facebook的,为什么呢?为什么你会显示为一个应用程序,可以处理我的意图,然后让我看起来愚蠢到我的用户可以通过不处理的意图是什么?你答应过Facebook的。

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.

我已经看到了这许多许多线程遍布这个网站,和网络。有没有人得到了这个,而不必使用自己的API来工作?

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?

推荐答案

这是我工作的解决方案如何通过有意在Facebook上共享图像。不幸的是,Facebook的不接受 EXTRA_TEXT 所以它只能将影像分享的。 它的工作原理与其它应用程序也和大多数人还可以添加文字标题。

This is my working solution how to share image on Facebook via intent. Unfortunately the Facebook is not accepting EXTRA_TEXT so it can only share the image. It works with other applications too and with most of them can add also text caption.

    /**
     * Show share dialog
     * @param file image to share
     * @param text text to add for sharing
     */
    private void shareImageAndTextResultIntent(File file, String text) {
        // share intent
        Intent shareIntent = new Intent();
        shareIntent.setAction(Intent.ACTION_SEND);
        shareIntent.putExtra(Intent.EXTRA_TEXT, text);
        shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
        shareIntent.setType("image/*");
        shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
        startActivity(Intent.createChooser(shareIntent, "send"));
    }

如果你想与字幕共享图像,你将不得不使用Facebook SDK。

If you want to share image along with caption, you'll have to use Facebook SDK.

这篇关于在Android上分享图片和文字与Facebook的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆