我想在 Facebook 上分享我的游戏得分。我检查了很多链接,每个帖子都说人们在 facebook 上使用 INTENT POSTING 是不可能。如果我们使用的是 Intent,那么我们可以仅分享链接。
如果我们必须在 facebook 上分享一些东西,我们必须使用 FaceBook SDK .
我还怀疑所有问题和答案都是在2014 年之前发布的。 2014 年后是否有任何新事物出现。
我的实际问题是,是否可以使用 Intent 在 Facebook 上分享分数,或者我必须使用 Facebook SDK? p>
下面是我用于我的应用程序的 Intent 代码,但它不工作......
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, message);
startActivity(Intent.createChooser(intent, "Share on"));
以下是 FacebookSDK 代码...问题在此不显示分数在帖子上仅显示链接图像 ,并且缺少标题和说明。
FacebookSdk.sdkInitialize(getApplicationContext());
shareDialog = new ShareDialog(this);
if (ShareDialog.canShow(ShareLinkContent.class)) {
linkContent = new ShareLinkContent.Builder()
.setContentTitle(title)
.setContentDescription(description)
.setContentUrl(Uri.parse(link)).
.setImageUrl(Uri.parse(imageLink)
.build();
shareDialog.show(linkContent);
}
我使用 ShareDialog 是因为
分享对话框切换到原生 Facebook for Android 应用程序,然后在帖子发布后将控制权返回给您的应用程序。如果未安装 Facebook 应用,它将自动退回到基于网络的对话框。
下面是输出...........
@pravin 这是您使用共享 API 后出现的错误
@Pravin 这是我分享答案的代码........
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FacebookSdk.sdkInitialize(getApplicationContext());
callbackManager = CallbackManager.Factory.create();
setContentView(R.layout.activity_facebook);
Button mShare= (Button) findViewById(R.id.share);
mShare.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ShareOpenGraphObject object = new ShareOpenGraphObject.Builder()
.putString("og:type", "game.achievement")
.putString("og:title", "Name of your game")
.putString("og:description", "description. You can share your score here")
.putString("game:points", "445")
.build();
ShareOpenGraphAction action = new ShareOpenGraphAction.Builder()
.setActionType("games.achieves")
.putObject("game", object)
.build();
if (ShareDialog.canShow(ShareLinkContent.class)) {
ShareOpenGraphContent content = new ShareOpenGraphContent.Builder()
.setPreviewPropertyName("game")
.setAction(action)
.build();
ShareDialog.show(Facebook.this, content);
}
}
});
shareDialog = new ShareDialog(this);
}
提前感谢......
最佳答案
经过长时间的搜索,我发现这是在我的项目中为我工作的,直到实际答案到来.......
FacebookSdk.sdkInitialize(getApplicationContext());
shareDialog = new ShareDialog(this);
if (ShareDialog.canShow(ShareLinkContent.class)) {
linkContent = new ShareLinkContent.Builder()
.setQuote("Hi Guys I have completed Game 30 in 19 seconds in this game")
.setImageUrl(Uri.parse("https://lh3.googleusercontent.com/jUej7mN6M6iulmuwmW6Mk28PrzXgl-Ebn-MpTmkmwtOfj5f0hvnuw8j0NEzK0GuKoDE=w300-rw"))
.setContentUrl(Uri.parse("https://play.google.com/store/apps/details?id=com.mobtraffiq.numbertap&hl=en"))
.build();
shareDialog.show(linkContent);
}
注意:-在此代码中,它共享一个配额。如果有人得到其他答案,请发布输出。
输出:-
如果你得到这个问题的实际答案,请发帖......
感谢所有努力的用户......
由于你的回答,我学到了很多东西......
享受编码............
关于android - 在 Facebook 安卓上分享分数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38759057/