I'm wondering if it is possible to change the text that says "SHARE DIALOG EXAMPLE". Where does this text come from? I'm using the latest SDK (4.10)
This is coming from the message you have set up. When you build your ShareLinkContent, add a custom message to say whatever you like. For example,
ShareLinkContent linkContent = new ShareLinkContent.Builder()
.setContentTitle(getString(R.string.facebook_title))
.setContentDescription(R.string.custom_msg)
.setContentUrl(Uri.parse(getActivity().getResources().getString(R.string.social_media_url)))
.build();
shareDialog.show(linkContent);
Related
I am developing an Android app. In my app, I am integrating Facebook API because I am sharing content from my app to Facebook. I am especially sharing link. So I am using ShareLinkContent option from official Facebook docs. I can successfully share on Facebook. But I am having a problem with this ShareLinkContent option because I cannot set the caption to post that is entered by user.
This is how I share to Facebook:
final ShareLinkContent content = new ShareLinkContent.Builder()
.setContentTitle(shareTitle)
.setImageUrl(Uri.parse(shareImageUrl))
.setContentUrl(Uri.parse(shareContentUrl))
.setContentDescription(shareDescription)
.build();
ShareApi.share(content, null);
I display preview before I share like this:
As you can see now, I can only show preview. But what I want is I want to add an EditText in the preview. The text entered will be shared as post caption on Facebook. But the problem is there is no option setCaption(textUserEntered) in the ShareLinkContent option. I also mentioned options available in the preview image as well.
How can I set post option for ShareLinkContent? That content will be entered by user. How can I get it? Is it possible to use with ShareLinkContent?
I found the solution. Actually I do not need to show custom preview to user. If I build the share content like below code, preview will the option to enter post caption will be automatically added.
final ShareLinkContent content = new ShareLinkContent.Builder()
.setContentTitle(shareTitle)
.setImageUrl(Uri.parse(shareImageUrl))
.setContentUrl(Uri.parse(shareContentUrl))
.setContentDescription(shareDescription)
.build();
ShareDialog shareDialog = new ShareDialog(this);
shareDialog.show(content);
So no need to use
ShareApi.share(content, null);
Here i am trying to share the page with hashtag.
ShareLinkContent linkContent = new ShareLinkContent.Builder()
.setContentTitle("Hello Facebook content tilte")
.setContentDescription("this is content description")
.setContentUrl(Uri.parse("https://www.facebook.com/Fishing-303261736469954/?fref=ts"))
.setImageUrl(Uri.parse("http://www.villathena.com/images/nearby/thumbs/le-bus-bleu-private-tours.jpg")) //Uri.parse("https://d3kvf6cfq06287.cloudfront.net/influencer/image2_1469508676.jpg"))
.setShareHashtag(new ShareHashtag.Builder().setHashtag(influencer.hashtag_name).build())
.build();
shareDialog.show(linkContent);
Problem am facing here is,
-> After posting, I am not getting the image in setImageUrl() in post, instead i am getting the shared page image.
Its for working fine(what i except) without setShareHashTag(),but my requirement is to include the hashtag.
Here i have attached the screenshots,
After posting,
I don't know what is missing,if any one know the answer please help !!
Thanks in advance.
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);
}
}
Is it possible to post on Facebook from my Android application and this post function as App Link? Where if someone using Facebook application tapped on this post it will be directed to G.P. to install my app, and if it's installed it will open my app with enough data to view this post in my app activity?
So far I couldn't find an example that shows how to create an App Link object, and how to include data in this object to be retrieved later from intent -> extras, and I'm totally confused how to implement it in Android.
For example, from my application I want to share an http://youtube.com/xxxxx link in a post on Facebook, how to create the App Link using Facebook App Link host feature?
Edit 1:
I need to understand something about app linking, do I create an app link for each post will be posted from my application, or app link is created once to represent my application?
Edit 2:
How to get my app name to be in Blue as Instagram and clicking on it opens my application or go to my Google Play to install if not installed
Edit 3:
This is the code I use to share, but I don't get my application name a "clickable blue link" as Instagram as in the picture:
ShareDialog shareDialog = new ShareDialog(mMainActivity);
if (ShareDialog.canShow(ShareLinkContent.class))
{
ShareLinkContent linkContent;
if(aURL == null)
{
linkContent = new ShareLinkContent.Builder().build();
}
else
{
linkContent = new ShareLinkContent.Builder()
.setContentUrl(Uri.parse(aURL))
.build();
}
shareDialog.show(linkContent);
}
Shall I make a specific changes in my application settings page on Facebook dashboard?
You should use open graph actions for that. first you should create a object . then add an action type. then needs to create a story. & you have to submit for review process your facebook app. Normally share code looks like this. read the docs https://developers.facebook.com/docs/sharing/opengraph/android. & you need to use app links - https://developers.facebook.com/docs/applinks/android
// Create an object
ShareOpenGraphObject object = new ShareOpenGraphObject.Builder()
.putString("og:type", "books.book")
.putString("og:title", "A Game of Thrones")
.putString("og:description", "In the frozen wastes to the north of Winterfell, sinister and supernatural forces are mustering.")
.putString("books:isbn", "0-553-57340-3")
.build();
// Create an action
ShareOpenGraphAction action = new ShareOpenGraphAction.Builder()
.setActionType("books.reads")
.putObject("book", object)
.build();
// Create the content
ShareOpenGraphContent content = new ShareOpenGraphContent.Builder()
.setPreviewPropertyName("book")
.setAction(action)
.build();
ShareDialog.show(activityOrFragment, content);
If I understand your question correctly, you want to post to facebook(a URL) from your app.
What you can do is:
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, your_link_here );
startActivity(Intent.createChooser(intent, "Share via"));
This will open up a list of apps where you can share your link which includes facebook app if it is installed. Also have a look at facebook's TOS. You cannot prefill a message as it is against their policy. If you want to share some text along with your URL you will have to use facebook's SDK.
I tried the same thing. It turns out that your app should be present on app center (facebook). Then only it will turn into blue link.
In my case, I tried clicking the link, but it landed on a page which said:
Misconfigured App Sorry, "My app" hasn't been approved for display in
App Centre.
So I got the hint from this.
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);
}