for my Android App Game I have implemented a Button that allows the user to share the result of a game.
I have integrated the Facebook SDK, so all classes are known to my project. The manifest contains the following tags:
<meta-data android:name="com.facebook.sdk.ApplicationId"
android:value="@string/app_id" />
<provider android:authorities="com.facebook.app.FacebookContentProvider16..."
android:name="com.facebook.FacebookContentProvider"
android:exported="true"/>
When I run the app I can share the result of the game with the code below.
public void onShareResult(View view){
FacebookSdk.sdkInitialize(getApplicationContext());
callbackManager = CallbackManager.Factory.create();
final ShareDialog shareDialog = new ShareDialog(this);
shareDialog.registerCallback(callbackManager, new FacebookCallback<Sharer.Result>() {
@Override
public void onSuccess(Sharer.Result result) {
Log.d(LOG_TAG, "success");
}
@Override
public void onError(FacebookException error) {
Log.d(LOG_TAG, "error");
}
@Override
public void onCancel() {
Log.d(LOG_TAG, "cancel");
}
});
if (shareDialog.canShow(ShareLinkContent.class)) {
ShareLinkContent linkContent = new ShareLinkContent.Builder()
.setContentTitle("Game Result Highscore")
.setContentDescription("My new highscore is " + sum.getText() + "!!")
.setContentUrl(Uri.parse("https://play.google.com/store/apps/details?id=de.ginkoboy.flashcards"))
//.setImageUrl(Uri.parse("android.resource://de.ginkoboy.flashcards/" + R.drawable.logo_flashcards_pro))
.setImageUrl(Uri.parse("http://bagpiper-andy.de/bilder/dudelsack%20app.png"))
.build();
shareDialog.show(linkContent);
}
}
However there are some things I do not understand.
Furthermore I have some trouble understanding what Facebook is requiring.
This is how Facebook displays my posting:
And this is how my App seem to post the content
So the question is: Where is my title and description gone???
Best regards
Oliver
Facebook Android SDK enables mobile developers build Facebook apps for Android. It includes features like tracking analytics, data trends, insights on the traffic on your app. User behaviour on how people interact with your app. It also helps track ads engagements, which ads are working which aren't.
So, I have found out the reason why my title and description was not visible in facebook.
First of all thanks @mustafasevgi but your solution refers to SDK 3.5.x where I tried to use SDK 4.0
Coming back to the solution...
I have found out that I have set up my content Url to my App inside the Google Play Store. If you set up a content Url outside of Google Play Store the title and description will not be overwritten.
you can use setQuote("Any Description String") method of ShareContent.Builder to set the quote to display for your link. Something like that
if (shareDialog.canShow(ShareLinkContent.class)) {
ShareLinkContent linkContent = new ShareLinkContent.Builder()
.setQuote("My new highscore is " + sum.getText() + "!!")
.setContentUrl(Uri.parse("https://play.google.com/store/apps/details?id=de.ginkoboy.flashcards"))
.build();
shareDialog.show(linkContent);
}
P.S. setTitle , setDescription and setImageUrl methods are deprecated now in Latest Facebook SDK
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With