Android的:如何通过文字意图在Facebook上分享图片吗? [英] Android: How to share image with text on facebook via intent?

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

问题描述

我想与大家分享的标题$ P $通过共享意图对填充从我的应用程序,Facebook上的照片。

I'd like to share a photo with caption pre-filled from my app via a share intent, on facebook.

例如code

Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.setType("image/*");      

intent.putExtra(Intent.EXTRA_TEXT, "eample");
intent.putExtra(Intent.EXTRA_TITLE, "example");
intent.putExtra(Intent.EXTRA_SUBJECT, "example");
intent.putExtra(Intent.EXTRA_STREAM, imageUri);

Intent openInChooser = new Intent(intent);
openInChooser.putExtra(Intent.EXTRA_INITIAL_INTENTS, extraIntents);
startActivity(openInChooser);

下面是截图我所得到的

如果一组类型为image / *然后照片被上传没有文字prefilled。如果将其设置为纯文本/照片无法显示.....

If a set type to image/* then a photo is uploaded without the text prefilled. If a set it to text/plain photo is not display.....

推荐答案

最新的Facebook版本不允许您共享使用文本意图。你必须使用Facebook SDK来做到这一点 - 做出这么简单,使用Facebook SDK + Android的简单的Facebook(<一href="https://github.com/sromku/android-simple-facebook">https://github.com/sromku/android-simple-facebook).使用该库,你的code会是这样(从简单的Facebook网站中提取):

The newest Facebook versions doesn't allow you to share text using intents. You have to use the Facebook SDK to do it - to make that simple, use the Facebook SDK + Android Simple Facebook (https://github.com/sromku/android-simple-facebook). Using the library, your code would be like this (extracted from the Simple Facebook site):

设置 OnPublishListener ,并呼吁:

  • 发布(饲料,OnPublishListener)无对话框。
  • 发布(饲料,真实,OnPublishListener)与对话。
  • publish(Feed, OnPublishListener) without dialog.
  • publish(Feed, true, OnPublishListener) with dialog.
  • 的消息 - 用户
  • 的消息
  • 名称 - 链接附件的名称
  • 标题 - 链接的标题(显示的链接名称下)
  • 说明 - 链接的描述(出现在链接标题下)
  • 图片 - 附加到这个帖子的图片的URL。图片必须至少为200像素由200像素
  • 链接 - 附加到这个帖子的链接
  • message - The message of the user
  • name - The name of the link attachment
  • caption - The caption of the link (appears beneath the link name)
  • description - The description of the link (appears beneath the link caption)
  • picture - The URL of a picture attached to this post. The picture must be at least 200px by 200px
  • link - The link attached to this post

初​​始化回调监听器:

Initialize callback listener:

OnPublishListener onPublishListener = new OnPublishListener() {
    @Override
        public void onComplete(String postId) {
            Log.i(TAG, "Published successfully. The new post id = " + postId);
        }

     /* 
      * You can override other methods here: 
      * onThinking(), onFail(String reason), onException(Throwable throwable)
      */
};

构建饲料:

Feed feed = new Feed.Builder()
    .setMessage("Clone it out...")
    .setName("Simple Facebook for Android")
    .setCaption("Code less, do the same.")
    .setDescription("The Simple Facebook library project makes the life much easier by coding less code for being able to login, publish feeds and open graph stories, invite friends and more.")
    .setPicture("https://raw.github.com/sromku/android-simple-facebook/master/Refs/android_facebook_sdk_logo.png")
    .setLink("https://github.com/sromku/android-simple-facebook")
    .build();

发布饲料对话框:

mSimpleFacebook.publish(feed, onPublishListener);

发布饲料对话框:

mSimpleFacebook.publish(feed, true, onPublishListener);

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

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