[英]Sharing on Facebook [Android]
I want to share image on Facebook with my android app. 我想用我的Android应用程序在Facebook上分享图像。 I use this code:
我用这个代码:
SharePhoto photo = (SharePhoto)new SharePhoto.Builder().SetBitmap(bitmap).Build();
SharePhotoContent content = new SharePhotoContent.Builder()
.AddPhoto(photo)
.Build();
_fbShareButton.ShareContent = content;
The problem is that i can only publish from account where i created facebook app. 问题是我只能从我创建Facebook应用程序的帐户发布。 After login to another account the share window doesn't appear.
登录到其他帐户后,不会显示共享窗口。
The app is online on facebook developer account. 该应用程序在Facebook开发者帐户上在线。
Thanks in advance! 提前致谢! :)
:)
First You have to make your app public in facebook developer. 首先你必须在facebook开发者中公开你的应用程序。 To make public Follow this steps given in this link https://stackoverflow.com/a/37982567/7235539
公开按照此链接中给出的步骤https://stackoverflow.com/a/37982567/7235539
Hope its help You. 希望对你有所帮助。
//If Your are in debug mode please make sure that you are login with developer id from which app is registered
FacebookSdk.sdkInitialize(context);//initialize your Facebook SDK
//Obtain Callback manager instance
CallbackManager callbackManager = CallbackManager.Factory.create();
//Create facebook Share Dialog instance
ShareDialog shareDialog = new ShareDialog((AppCompatActivity) context
//Register CallBack
shareDialog.registerCallback(callbackManager, new FacebookCallback<Sharer.Result>() {
@Override
public void onSuccess(Sharer.Result result) {
}
@Override
public void onCancel() {
}
@Override
public void onError(FacebookException error) {
error.printStackTrace();
}
});
//Perform Click event on your share button
fb_share_btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (ShareDialog.canShow(ShareLinkContent.class)) {
ShareLinkContent content = new ShareLinkContent.Builder()
.setContentUrl(Uri.parse(context.getString(R.string.app_link_to_play_store)))//this is your play store link
.setContentTitle(context.getString(R.string.app_name))
.setContentDescription(context.getString(R.string.description_content_fb))//content to display on facebook
.setImageUrl(Uri.parse("Your image url placed on app server"))
.build();
shareDialog.show(content);
}
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.