FaceBook共享在android中不起作用

时间:2014-05-19 06:13:45

标签: android facebook facebook-graph-api

您好我正在尝试在Facebook上实现文本共享,我已经在完成这些程序后在Facebook上使用必要的信息创建了应用程序,我在我的应用程序上实现了Facebook共享,每当我尝试使用我的帐户在Facebook上发布消息(我已经习惯于创建appID )它已在facebook上发布但如果我尝试使用其他一些Facebook帐户发布消息则不会,该帐户会登录但是它赢了将帖子发布在墙上。请事先感谢任何人帮助我摆脱这个问题

1 个答案:

答案 0 :(得分:1)

参考https://stackoverflow.com/a/15783274/2771869

使用Facebook SDK从用户墙上分享:

private void share() {
    Bundle bundle = new Bundle();
    bundle.putString("caption", "Harlem Shake Launcher for Android");
    bundle.putString("description", "Your android can do the Harlem Shake. Download it from google play");
    bundle.putString("link", "https://play.google.com/store/apps/details?id=mobi.shush.harlemlauncher");
    bundle.putString("name", "Harlem Shake Launcher");
    bundle.putString("picture", "http://shush.mobi/bla.png");
    new WebDialog.FeedDialogBuilder(mContext, mySession, bundle).build().show();
}

如果您需要登录(在您需要登录/分享的任何地方添加此活动):

Session.openActiveSession(this, true, new Session.StatusCallback() {

    @Override
    public void call(Session session, SessionState state, Exception exception) {
        if(session.isOpened()) {
            share();
        }
    }
});

您需要添加到您的活动中:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    switch(requestCode) {
    default:
        if(Session.getActiveSession() != null) //I need to check if this null just to sleep peacefully at night
            Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data);
        break;
    }
}
相关问题