1

I am developing an android application that share data on Facebook. I am using Facebook SDK 3.0.2 I successfully implemented login authentication and I also implemented Facebook sharing but it creates problem while Facebook App already installed in device.

If device already has the Facebook app than my app goes to native Facebook app login and sharing method and it login successfully, but when I click to share it shows "myApp would like to access your public profile and friend list." and when I clicked on Ok button it does nothing. I searched a lot but don't find any useful solution and also didn't found any solution for this in Facebook documentation.

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();
}
Jason C
  • 38,729
  • 14
  • 126
  • 182
nishitpatel
  • 652
  • 4
  • 9
  • 25

1 Answers1

1

Add this when you declare the LoginButton:

authButton.setLoginBehavior(SessionLoginBehavior.SUPPRESS_SSO);

Geltrude
  • 1,093
  • 3
  • 17
  • 35