我正在开发一个在 Facebook 上共享数据的 android 应用程序。我正在使用Facebook SDK 3.0.2
我成功实现了登录身份验证,并且我还实现了 Facebook 共享,但是当 Facebook 应用程序已经安装在设备中时它会产生问题。
如果设备已经有 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();
}