How to share photos on facebook with android programmatically - android

I follow facebook's tutorial and I want to share my application screen shot so i used code on below.But it didn't also i can be log in.
SharePhoto photo = new SharePhoto.Builder()
.setBitmap(bm)
.build();
SharePhotoContent content = new SharePhotoContent.Builder()
.addPhoto(photo)
.build();
ShareDialog shareDialog1 = new ShareDialog(Oyun.this);
shareDialog1.show(content);

Please visit this answer given by this guy he share photos as well as include caption with it
How to share photo with CAPTION via Android share intent on Facebook?
You need to make a simple intent to Facebook for it and you can share it. Just go through the above answer and you will find it out very easy.

Related

Multiple Hasthag on Facebook Share Android

I manage to create an app that can share picture along with the hasthag with this facebook sdk version 4.+.
In my app I have three checkbox that each contains the option of hasthag people want to share.
With the code i currently have
SharePhoto photo = new SharePhoto.Builder()
.setBitmap(bitmap)
.build();
SharePhotoContent content = new SharePhotoContent.Builder()
.addPhoto(photo)
.setShareHashtag(new ShareHashtag.Builder()
.setHashtag(hastag1).build())
.build();
ShareDialog.show(SelfieActivity.this,content);
Can only post one hasthag. I have tried setting the hasthag as
.setHashtag(hastag1+" "+hastag2+" "+hastag3)
Only post the first one.
Anybody knows how to post multiple hasthag?
Unfortunately Facebook only allowed one hashtag

How to share image on Facebook with Caption from android?

I tried sharing an Image with Caption on Facebook with the help of Facebook API and the code as below:
SharePhoto photo = new SharePhoto.Builder()
.setBitmap(image)
.setCaption("Caption is Important")
.build();
SharePhotoContent content = new SharePhotoContent.Builder()
.addPhoto(photo)
.build();
shareDialog.show(content);
It open up the ShareDialog but the caption wont appear in it the dialog
As per the facebook documentation shared CBroe:
https://developers.facebook.com/policy#control
According to its policy 2.3 it states that
Don't prefill captions, comments, messages, or the user message parameter of posts with content a person or business didn’t create, even if the person can edit or remove the content before sharing. You may use our Share Dialogs to prefill a single hashtag in a post, but don't prefill any content a person or business didn't create via the API.
So we are no longer allowed to pre-fill captions for images by using shareDialog or by using any other method.
You can add caption with the given method. But at share dialog of facebook. You have to manually type your caption.

Can i share an image from my app to any other public facebook page ? n how?

Bellow is the code which enables to share image only within my network on facebokk page.
private void sharePhotoToFacebook(){
Log.e("in sharemethod", "hiiiiii");
Bitmap image = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher);
SharePhoto photo = new SharePhoto.Builder()
.setBitmap(image)
.setCaption("Give me my codez or I will ... you know, do that thing you don't like!")
.build();
SharePhotoContent content = new SharePhotoContent.Builder()
.addPhoto(photo)
.build();
shareDialog.show(content);}
I want to to share an image to the pages not in my facebook network.
Unfortunately you can not share !
Facebook does not allow it because for this you need access tokens of the pages and if you wanna share through app on pages for this it is needed that the page which are not your network must allow you app to do so.And you also need to get permissions first from the Facebook such as posting permission or etc :)

How to set description or title to Facebook photo share with PhotoShareContent in Android

I am developing an Android app. In my app, I am integrating Facebook photo share feature. This is my first Android app with Facebook integration. I am able to share photo to user timeline now. But I am having problem with setting description to that image.
This is my Facebook share photo function
private void sharePhotoToFacebook(){
SharePhoto photo = new SharePhoto.Builder()
.setBitmap(shareBitmap)
.build();
SharePhotoContent content = new SharePhotoContent.Builder()
.addPhoto(photo)
.build();
ShareApi.share(content, null);
}
When photo shared it shows like this in timeline
As you can see there is no description or title. What I want is I want to set title or description. Is there any function can do like below
SharePhotoContent content = new SharePhotoContent.Builder()
.addPhoto(photo).setCaption("Description")
.build();
How can I set title?
Write setCaption() method as below:
SharePhoto photo = new SharePhoto.Builder()
.setBitmap(shareBitmap)
.setCaption("Description")
.build();
Note: need to use SDK vertion 4+. Means at least 4.1
compile 'com.facebook.android:facebook-android-sdk:4.+'
As per Facebook Platform Policies (2.3) you cannot set caption from your app. Read this note from documentation.
setCaption(String)
Sets the user generated caption for the photo. Note that the 'caption' must come from the user, as pre-filled content is forbidden by the Platform Policies (2.3).

Facebook-Android-SDK v3.6 ShareDialog attach bitmap

I've poured through the documentation, and it appears as though it is not possible to simply share a local user generated image through the ShareDialog provided in the SDK?
Can someone confirm if this is indeed the case? If it is possible, how can I do this? I only ask because it is possible to do this through OpenGraphActionDialogBuilder via setImageAttachmentsForAction, but not ShareDialogBuilder.(ex: Posting photo from a native ShareDialog in Facebook android SDK)
All I want to do is to post a status update with an image, I don't want to create link to another URL, which is required by the OpenGraphActionDialogBuilder.
It's an old question but here is my solution with the latest Facebook API:
Bitmap image = BitmapFactory.decodeResource(getResources(), R.drawable.scrat);
SharePhoto photo = new SharePhoto.Builder()
.setBitmap(image)
.build();
SharePhotoContent content = new SharePhotoContent.Builder()
.addPhoto(photo)
.build();
ShareDialog dlg = new ShareDialog(MainActivity.this);
if(dlg.canShow(SharePhotoContent.class)){
dlg.show(content);
}
Don't forget you have to be logged.

Categories

Resources