4

I am working on android Application. when facebook native application installed it does not work and show only two popup. but if itis not installed it redirect to facebook website and works fine .How i can resolve this . any help will be appreciated. I have checked and added all hashkey in facebook app. but still not working .

    statusCallback = new SessionStatusCallback();
    Session session = Session.getActiveSession();
    this.isLogin = isLoginUser;
    session = null;
    if (session == null) {
        if (savedInstanceState != null) {
            session = Session.restoreSession(context, null,                        statusCallback,savedInstanceState);
        }
        if (session == null) {

            session = new Session.Builder(context).setApplicationId(
                    "688998947797106").build();

        }
        Session.setActiveSession(session);
        if (session.getState().equals(SessionState.CREATED_TOKEN_LOADED)) {
            session.openForRead(new Session.OpenRequest(activity)
                    .setCallback(statusCallback)
                    .setLoginBehavior(
                            SessionLoginBehavior.SSO_WITH_FALLBACK)
                    .setPermissions(Arrays.asList("email")));
        }
    }
    if (!session.isOpened() && !session.isClosed()) {
        session.openForRead(new Session.OpenRequest(activity)
                .setCallback(statusCallback)
                .setLoginBehavior(SessionLoginBehavior.SSO_WITH_FALLBACK)
                .setPermissions(Arrays.asList("email")));
    } else {
        Session.openActiveSession(activity, true, statusCallback);
    }
Nitesh Kabra
  • 265
  • 1
  • 3
  • 7

3 Answers3

3

I also Had same problem, I have added different key. See my Question Here

You will get more Information on this discussion Click here See The answer given By Abhishek Agrawal in that Link.

Add following code to your Activities onCreate and check which hashkey is sent by your app to facebook,

PackageInfo info;
    try {
        info = getPackageManager().getPackageInfo("com.example.yourpackagename", PackageManager.GET_SIGNATURES);
        for (Signature signature : info.signatures) {
            MessageDigest md;
            md = MessageDigest.getInstance("SHA");
            md.update(signature.toByteArray());
            String something = new String(Base64.encode(md.digest(), 0));
            //String something = new String(Base64.encodeBytes(md.digest()));
            Log.e("hash key", something);
        }
    } catch (NameNotFoundException e1) {
        Log.e("name not found", e1.toString());
    } catch (NoSuchAlgorithmException e) {
        Log.e("no such an algorithm", e.toString());
    } catch (Exception e) {
        Log.e("exception", e.toString());
    }
Community
  • 1
  • 1
Straw Hat
  • 902
  • 14
  • 38
2

First Check your hash key with these lines of code given by me at this link Facebook Integration in Android Application and if it is not working yet then please check that your Facebook Android Application in mobile is updated. If the application is not updated update your Facebook application and try to post.

Community
  • 1
  • 1
Abhishek Agarwal
  • 1,907
  • 12
  • 21
0
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    facebook.authorizeCallback(requestCode, resultCode, data);
}

Use this code in the activity where you call facebook login request.

atrivedi
  • 348
  • 1
  • 4
  • 12