title: Facebook Android SDK does not open Session after login
body: <p>1) This question appears many times and the awnser is always "you have the wrong Key Hash". </p>
  
  <p>2) Facebook documentation tells we to use this code to get our Key Hash:</p>
  
  <pre><code>keytool -exportcert -alias MyKeyAlias -keystore path\to\my\Key | openssl sha1 -binary | openssl base64
  </code></pre>
  
  <p>3) Ok, this gives me that key: 1yl**********Q3A</p>
  
  <p>When I try to login, I got the following message:
      com.facebook.http.protocol.ApiException: (#404) Key hash XHA**********q10 does not match any stored key hashes.</p>
  
  <p>4) Then I copy and paste the XHA**********q10 on my app settings and thats not my key either.</p>
  
  <p>5) So, I read on documentation that was a code that gives you the correct Key Hash. This code:</p>
  
  <pre><code>// Add code to print out the key hash
  try {
      PackageInfo info = getPackageManager().getPackageInfo(
              "com.facebook.samples.hellofacebook", 
              PackageManager.GET_SIGNATURES);
      for (Signature signature : info.signatures) {
          MessageDigest md = MessageDigest.getInstance("SHA");
          md.update(signature.toByteArray());
          Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
          }
  } catch (NameNotFoundException e) {
  
  } catch (NoSuchAlgorithmException e) {
  
  }
  </code></pre>
  
  <p>It worked! Gave me this hash: +HA**********q0=</p>
  
  <p>6) I put this last hash on app settings and YES, now I can connect! BUT, now I can't open a Session!!!</p>
  
  <p>I'm using the following code:</p>
  
  <pre><code>public class FBActivity extends Activity {
  
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.my_view);
  
          System.out.println("Start Facebook login");
          Session.openActiveSession(this, true, new Session.StatusCallback() {
              public void call(Session session, SessionState state, 
                                                Exception exception) {
                  System.out.println("Call");
                  if (session.isOpened()) {
                      System.out.println("Open");
                      Request.newMeRequest(session, new Request.GraphUserCallback() {
                          public void onCompleted(GraphUser user, Response response) {
                              System.out.println("Complete");
                              if (user != null) {
                                  System.out.println(user.getName());
  
                              } else {
                                  System.out.println("User NULL");
                              }
                          }
                      }).executeAsync();
                  } else {
                  System.out.println("Not open");
              }
  
          });
      }
  }
  </code></pre>
  
  <p>And the log is:</p>
  
  <p>"Start Facebook Login</p>
  
  <p>Call</p>
  
  <p>Not open</p>
  
  <p>Call</p>
  
  <p>Not open"</p>
  
  <p>I don't know what else can I do, since I already have the correct Key Hash and I can make the login.</p>