When I share link with referrer, Facebook SDK (v4.8) will remove it from link.
For example I have following link:
https://play.google.com/store/apps/details?id=com.mypackage.myapp&referrer=utm_source%3Dfacebook
The actual post on wall contains link without referrer:
http://play.google.com/store/apps/details?id=com.mypackage.myapp
Code:
if (ShareDialog.canShow(ShareLinkContent.class)) {
ShareLinkContent content = new ShareLinkContent.Builder()
.setContentUrl(Uri.parse("https://play.google.com/store/apps/details?id=com.mypackage.myapp&referrer=utm_source%3Dfacebook"))
.build();
shareDialog.show(content);
}
Related
Is there any way to share image and link on facebook in android. I tried below code without success.
ShareLinkContent linkContent = new ShareLinkContent.Builder()
.setContentTitle("Test")
.setContentDescription("Simple Test")
.setContentUrl(Uri.parse("https://material.io/icons/"))
.setImageUrl(Uri.parse("https://data.kaktus.media/file/file/2017-12-08_16-29-44_928522.jpg"))
.build();
AFAIK setImageUrl is now deprecated. The problem is the ImageUrl image is replaced by the ContentUrl image as mentioned in this question FaceBook ShareLinkContent setImageUrl is replaced by ContentUrl metadata in android.
my problem is that i am not able to see content title and content description of my sharing image using facebook share in android app.
my code is
if (shareDialog.canShow(ShareLinkContent.class)) {
ShareLinkContent linkContent = new ShareLinkContent.Builder()
.setContentTitle("Content Title")
.setImageUrl(Uri.parse(getIntent().getStringExtra("shareValue")))
.setContentDescription("Content Description")
.build();
shareDialog.show(linkContent); // Show facebook ShareDialog
}
sharing those parameters has been disabled in Facebook graph API
Modeling content
I need to share image along with the text and pre-populated hash tag to facebook. So i integrate facebook SDK for sharing.For that i used the following code:-
SharePhoto photo = new SharePhoto.Builder()
.setBitmap(image)
.build();
SharePhotoContent content = new SharePhotoContent.Builder()
.addPhoto(photo)
.setShareHashtag(new ShareHashtag.Builder()
.setHashtag("#loveloqal").build())
.build();
Now i can populate the image and hash tag But can't populate the text.i heard that the posting userdefined posts are against the privacy policy of facebook.Is there any way to do this.I searched a lot.Can someone help me to find a solution??
you can use SharelinkContent https://developers.facebook.com/docs/reference/android/current/class/ShareLinkContent/
It is added in facebook-android-sdk:4.6.0
<provider
android:authorities="com.facebook.app.FacebookContentProvider{APP_ID}"
android:name="com.facebook.FacebookContentProvider"
android:exported="true" />
To use it:
Create a provider in your manifest.xml file like above
ShareLinkContent shareLinkContent = new ShareLinkContent.Builder()
.setContentTitle("Your Title")
.setContentDescription("Your Description")
.setContentUrl(Uri.parse("URL[will open website or app]"))
.setImageUrl(Uri.parse("image or logo [if playstore or app store url then no need of this image url]"))
.build();
create Sharelink content with data and image
Show the dialog.
ShareDialog.show(ShowNavigationActivity.this,shareLinkContent);
After some research there is i found that SharelinkContent has bugs in facebook sdk
see this: Description not shown in Facebook ShareDialog
you can use Open Graph instead... see this:
1.https://developers.facebook.com/docs/sharing/opengraph/android
And
How to share Title and description from android to facebook using facebook sdk 4.1.2
Hope it helps u...
I am working on an app that I want to be able to post to Facebook wall. The language used for the app is non-latin based character set. Hence, the user types the content to share using the app itself and then share it on facebook without going to the ShareDialog as the content is already typed. I am using Facebook SDK for Android 4.+. Can anyone help me on doing this? All example I got is posting using ShareDialog. Facebook SDK seems to have classes like ShareLinkContent, SharePhoto, ShareMedia but no class to attach simple text content which I am trying to do. Or, can I make the content already typed appear on the ShareDialog's EditText?
Facebook does not allow you to pre-fill the ShareDialog's text. As far as I know there also is no other way to post content on a user's wall.
What is possible is share a link using the ShareDialog, and you can pre-fill the link description and other attributes like image and title but I guess that's not what you want.
An example of that is:
ShareLinkContent content = new ShareLinkContent.Builder()
.setContentDescription(descriptionString)
.setContentUrl(Uri.parse(urlString))
.setImageUrl(Uri.parse(pictureUrlString))
.setContentTitle(titleString)
.build();
ShareDialog dialog = new ShareDialog(this);
dialog.show(content);
private void showFacebookShareDialog() {
if (ShareDialog.canShow(ShareLinkContent.class)) {
ShareLinkContent linkContent = new ShareLinkContent.Builder()
.setContentTitle("Title")
.setContentDescription(
"Share Text")
.setContentUrl(Uri.parse("http://developers.facebook.com/android"))
.build();
shareDialog.show(linkContent);
}
}
I'm using the Facebook Android SDK to post a share from my Android app, setting the link to the Google Play url but I want to fill in my own description to be displayed. My description shows up in my preview when I'm posting from my app, but when it gets displayed all that shows is "GET IT ON GOOGLE PLAY" and my description has disappeared.
I am modifying code taken from the Facebook share tutorial included in the SDK (currently using version 3.19.0), here is the ShareDialogBuilder code:
private FacebookDialog.ShareDialogBuilder createShareDialogBuilderForLink() {
return new FacebookDialog.ShareDialogBuilder(this)
.setLink(webLink)
.setName(getString(R.string.fb_name))
.setDescription("Here is my description that I want included in the post.")
.setPicture("http://www.website.com/images/icon.png");
}
I use Facebook SDK 4.0 and this method works fine
if (ShareDialog.canShow(ShareLinkContent.class)) {
ShareLinkContent linkContent = new ShareLinkContent.Builder()
.setContentTitle(getString(R.string.share_onfacebook_title))
.setContentDescription(
getString(R.string.share_onfacebook_message))
.setContentUrl(Uri.parse(getString(R.string.share_onfacebook_url)))
.setImageUrl(Uri.parse(getString(R.string.share_onfacebook_image_url)))
.build();
shareDialog.show(linkContent);
}