找到你要的答案

Q:Share Image and Text to Facebook on android

Q:在Android上分享脸谱网的图像和文字

What is the correct way to share an image and text to Facebook in android? e.g. picture with pre-populated text.

I realise that this is not possible from the native Android share intent as described here. As it can only take an image or a link not both.

Also I have tried using the facebook-sdk-3.14 with:

    FacebookDialog.ShareDialogBuilder 

but I now realise this is for sharing links only.

I have also tried with:

    createShareDialogBuilderForPhoto() 

but this is for sharing images only.

Is there something I am missing in the sdk? I am guessing it is not possible from FacebookDialog?

Will I need to go the route of creating my own app in facebook and my own open graph action? Ideally I am looking to not have a login button.

I have also seen similar questions but most are about the share intent or if it is the sdk it at least a year out of date and the solution is some thing similar to this:

    Bundle parameters = new Bundle();
            parameters.putString("message", category_item_name_desc.getText().toString());
            parameters.putString("picture", categoryItemsModel.getImageUrl());
            parameters.putString("caption", txtDescription_desc.getText().toString());
            facebook.request("/me/feed", parameters, "POST");

Tried it through the Feed Dialog (WebDialog) but im getting a "error (#324) requires upload file", Any help would be great.

What is the correct way to share an image and text to Facebook in android? e.g. picture with pre-populated text.

我意识到这是不可能从本地Android共享意图这里所描述的。因为它只能采取图像或链接不两者。

我也试过用facebook-sdk-3.14与:

    FacebookDialog.ShareDialogBuilder 

但我现在意识到这仅仅是为了分享链接。

我也尝试过:

    createShareDialogBuilderForPhoto() 

但这只是为了分享图像。

有什么我失踪的?我猜从facebookdialog这是不可能的吗?

我需要在脸谱网和我自己的开放图行动中创建自己的应用程序吗?理想的情况下,我希望没有登录按钮。

我也看到了类似的问题,但大多数都是关于分享的意图,或者如果它是SDK至少一年的日期和解决方案有点类似于此:

    Bundle parameters = new Bundle();
            parameters.putString("message", category_item_name_desc.getText().toString());
            parameters.putString("picture", categoryItemsModel.getImageUrl());
            parameters.putString("caption", txtDescription_desc.getText().toString());
            facebook.request("/me/feed", parameters, "POST");

试图通过饲料对话框(webdialog)但我得到一个错误(# 324)需要上传文件”,任何帮助将是巨大的。

answer1: 回答1:

You can share your image on facebook, Twitter, and Gmail:

Bitmap b =BitmapFactory.decodeResource(getResources(),R.drawable.ic_launcher);

Intent share = new Intent(Intent.ACTION_SEND);

share.setType(“image/jpeg”);

ByteArrayOutputStream bytes = new ByteArrayOutputStream();
b.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
String path = MediaStore.Images.Media.insertImage(getContentResolver(), b, “Title”, null);
Uri imageUri = Uri.parse(path);
share.putExtra(Intent.EXTRA_STREAM, imageUri);
startActivity(Intent.createChooser(share, “Select”));

你可以在脸谱网,推特分享您的图像,和Gmail:

Bitmap b =BitmapFactory.decodeResource(getResources(),R.drawable.ic_launcher);

Intent share = new Intent(Intent.ACTION_SEND);

share.setType(“image/jpeg”);

ByteArrayOutputStream bytes = new ByteArrayOutputStream();
b.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
String path = MediaStore.Images.Media.insertImage(getContentResolver(), b, “Title”, null);
Uri imageUri = Uri.parse(path);
share.putExtra(Intent.EXTRA_STREAM, imageUri);
startActivity(Intent.createChooser(share, “Select”));
answer2: 回答2:

Was able to do this my self with the current Facebook SDK (3.14.1 at the time) with no login and I made it into a share intent for adding to the chooser list.

I have a demo project at https://github.com/b099l3/FacebookImageShareIntent only dependency is the facebook sdk and it is contained in one activity.

能够与当前的脸谱网SDK做我自己(3.14.1当时)没有登录,我进了一股故意添加到选择器列表。

我在https://github.com/b099l3/facebookimageshareintent只依赖一个演示项目是脸谱网的SDK,它包含在一个活动。

answer3: 回答3:

Please take a look a look on my library: https://github.com/antonkrasov/AndroidSocialNetworks

With help of it, posting is really easy:

mSocialNetworkManager.getFacebookSocialNetwork().postMessage(String message)
mSocialNetworkManager.getFacebookSocialNetwork().postPhoto(File path...)

请看我的图书馆一看:https://github.com/antonkrasov/androidsocialnetworks

有了它的帮助,发帖真的很容易:

mSocialNetworkManager.getFacebookSocialNetwork().postMessage(String message)
mSocialNetworkManager.getFacebookSocialNetwork().postPhoto(File path...)
android  facebook  facebook-sdk-3.14.x