我正在开发一个在Facebook上共享数据的Android应用程序。我正在使用Facebook SDK 3.0.2
我成功实现了登录身份验证,我也实现了Facebook共享,但是当Facebook App已经安装在设备中时会产生问题。
如果设备已经拥有Facebook应用程序而不是我的应用程序转到本地Facebook应用程序登录和共享方法并且登录成功,但当我点击分享它时显示“myApp想要访问您的公开个人资料和朋友列表。“当我点击”确定“按钮时,它什么也没做。我搜索了很多,但没有找到任何有用的解决方案,也没有在Facebook文档中找到任何解决方案。
private void publishFeedDialog(String title, String description,
String time, String imageUrl) {
String fileId = m_YouScoopList.get(mShareIndex).file_id;
String linkUrl = "";
if (m_YouScoopList.get(mShareIndex).file_type_id.equals("2")) {
linkUrl = "http://www.mywebsite.com/news/my/imageshare/"
+ fileId;
} else {
linkUrl = "http://www.mywebsite.com/news/imageshare/videoshare/"
+ fileId;
}
Bundle params = new Bundle();
params.putString("name", "" + title);
params.putString("caption", "" + time);
params.putString("description", "" + description);
params.putString("link", linkUrl);
params.putString("picture", "" + imageUrl);
WebDialog feedDialog = (new WebDialog.FeedDialogBuilder(
MainActivity5.this, Session.getActiveSession(), params))
.setOnCompleteListener(new OnCompleteListener() {
public void onComplete(Bundle values,
FacebookException error) {
// TODO Auto-generated method stub
if (error == null) {
// When the story is posted, echo the success
// and the post Id.
final String postId = values.getString("post_id");
if (postId != null) {
Toast.makeText(MainActivity5.this,
"Posted on facebook successfully!",
Toast.LENGTH_SHORT).show();
} else {
// User clicked the Cancel button
Toast.makeText(
MainActivity5.this
.getApplicationContext(),
"Publish cancelled", Toast.LENGTH_SHORT)
.show();
}
} else if (error instanceof FacebookOperationCanceledException) {
// User clicked the "x" button
Toast.makeText(
MainActivity5.this.getApplicationContext(),
"Publish cancelled", Toast.LENGTH_SHORT)
.show();
} else {
// Generic, ex: network error
Toast.makeText(
MainActivity5.this.getApplicationContext(),
"Error posting story", Toast.LENGTH_SHORT)
.show();
}
}
}).build();
feedDialog.show();
}
答案 0 :(得分:1)
声明LoginButton:
时添加此项authButton.setLoginBehavior(SessionLoginBehavior.SUPPRESS_SSO);