这是我的问题:我想让我的应用程序能够在Facebook上用自动设置的标签共享图片。 我搜索了facebook文档,并尝试了一些代码。
我目前能够登录并发布图片,完全没问题,但我看不到主题标签(或任何错误)
这是我的代码:
sharedialog = new ShareDialog(this);
SharePhoto photo = new SharePhoto.Builder()
.setBitmap(bitmap)
.build();
SharePhotoContent content = new SharePhotoContent.Builder()
.addPhoto(photo)
.setShareHashtag(new ShareHashtag.Builder()
.setHashtag("#FollowTheSun")
.build())
.build();
if (sharedialog.canShow(content)) {
ShareDialog.show(this, content);
}
我做错了什么? 谢谢你的帮助!
答案 0 :(得分:0)
请尝试一下
public void shareFb() {
if (isFacebookExist()) {
if (CheckButton.isChecked()) {
SharePhoto sharePhoto = new SharePhoto.Builder()
.setBitmap(updateImage)//image location
.build();
if (ShareDialog.canShow(SharePhotoContent.class)) {
SharePhotoContent content = new SharePhotoContent.Builder()
.addPhoto(sharePhoto)
.setShareHashtag(new ShareHashtag.Builder()
.setHashtag("#YOURHASHTAG")
.build())
.build();
shareDialog.show(content);
}
} else {
SharePhoto sharePhoto = new SharePhoto.Builder()
.setBitmap(updateImage)
.build();
if (ShareDialog.canShow(SharePhotoContent.class)) {
SharePhotoContent content = new SharePhotoContent.Builder()
.addPhoto(sharePhoto)
.build();
shareDialog.show(content);
}
}
} else {
showToast(" Facebook is not install.");
}
}
private boolean isFacebookExist() {
PackageManager pm = getPackageManager();
try {
PackageInfo info = pm.getPackageInfo("com.facebook.katana", PackageManager.GET_META_DATA);
} catch (PackageManager.NameNotFoundException e) {
return false;
}
return true;
}