0

I am developing a news app in Android and I can share any news on Facebook via my app. But when I log out of Facebook via my application I can't log in again by using the same Facebook's application ID and can't share news.

Is it possible to log in Facebook again after logging out by using same Facebook's application ID?

ChuongPham
  • 4,761
  • 8
  • 43
  • 53
Ufuk Garip
  • 43
  • 1
  • 7
  • how do you log out from facebook ? – Nadir Belhaj Sep 12 '14 at 16:34
  • I log out via my application – Ufuk Garip Sep 12 '14 at 16:40
  • private void onSessionStateChange(Session session, SessionState state,Exception exception){ if(state.isOpened()){ Log.i(TAG, "Logged in..."); shareButton.setVisibility(View.VISIBLE); if(pendingPublishReauthorization && state.equals(SessionState.OPENED_TOKEN_UPDATED)){ pendingPublishReauthorization=false; publishStory(); } }else if(state.isClosed()){ Log.i(TAG, "Logged out..."); shareButton.setVisibility(View.INVISIBLE); } } – Ufuk Garip Sep 12 '14 at 16:40

2 Answers2

1

We had same problem.

It was because we were targeting the production Facebook App ID but we were testing on a device with our IDE, without signing the app.

When you just hit the "run" button of your IDE, application is not signed with the release key so Facebook will complain about a hash mismatch.

If you create a signed APK with the same keystore you used to generate your production hash key you won't have the problem anymore.

more on this here : Android Facebook SDK 3.0 gives "remote_app_id does not match stored id" while logging in

Community
  • 1
  • 1
Guillaume Gendre
  • 2,504
  • 28
  • 17
0

try logging out using this snippet

private void logout(){
    // clear any user information
    mApp.clearUserPrefs();
    // find the active session which can only be facebook in my app
    Session session = Session.getActiveSession();
    // run the closeAndClearTokenInformation which does the following
    // DOCS : Closes the local in-memory Session object and clears any persistent 
    // cache related to the Session.
    session.closeAndClearTokenInformation();
    // return the user to the login screen
    startActivity(new Intent(getApplicationContext(), LoginActivity.class));
    // make sure the user can not access the page after he/she is logged out
    // clear the activity stack
    finish();
}
Nadir Belhaj
  • 11,953
  • 2
  • 22
  • 21
  • it doesn't work for me,when i log in again by using same face app id after log out it says that Invalid key hash The key hash DvPzSZrXjg.... does not matchany stored key hashs and my hash key is not this(DvPzSZrXjg....) – Ufuk Garip Sep 12 '14 at 17:09