Android的Facebook的API和ShareLinkContent [英] Android Facebook API and ShareLinkContent
问题描述
我的Android应用游戏我实现了一个按钮,允许用户分享比赛的结果。
for my Android App Game I have implemented a Button that allows the user to share the result of a game.
我已经集成Facebook的SDK,所以所有的类都知道我的项目。
清单包含以下标签:
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"/>
当我运行应用程序,我可以分享下面的code本场比赛的结果。
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.
- 共享链接看起来从我的对话框中看到我发布之前不同。
- 图片似乎通过互联网一直可用。即它不可能从我的项目设置资源的图像。
此外,我有一些麻烦,了解什么是Facebook的要求。
Furthermore I have some trouble understanding what Facebook is requiring.
这是Facebook的如何显示我的帖子:
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???
最好的问候
奥利弗
推荐答案
所以,我已经找到了,为什么我的标题和描述是不是在Facebook中可见的原因。
So, I have found out the reason why my title and description was not visible in facebook.
这一切都归功于@mustafasevgi但您的解决方案是指SDK 3.5.x的,我试图用SDK 4.0的第一个
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...
我发现,我已经建立了我的内容链接到我的应用程序在谷歌Play商店内。如果你设置了一个内容URL谷歌以外的Play商店的标题和描述将不会被覆盖。
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.
这篇关于Android的Facebook的API和ShareLinkContent的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!