title: Get Facebook user ID with android SDK 4.0
body: <p>How can I get the Facebook User ID with the Facebook Android SDK 4.0?</p>
  
  <p>Here is my code that doesn't work: </p>
  
  <pre><code>protected void onCreate(Bundle savedInstanceState)
  {
      super.onCreate(savedInstanceState);
      FacebookSdk.sdkInitialize(getApplicationContext());
      setContentView(R.layout.activity_firstlogin);
  
      CallbackManager cm;
      LoginButton     lb;
  
      cm = CallbackManager.Factory.create();
      lb = (LoginButton) findViewById(R.id.facebook_button);
      Log.d(TAG, "Salut les zouzous");
      LoginManager.getInstance().registerCallback(cm,
              new FacebookCallback&lt;LoginResult&gt;()
              {
                  @Override
                  public void onSuccess(LoginResult loginResult)
                  {
                     Log.d(TAG, "Success !");
                      AccessToken tok;
                      tok = AccessToken.getCurrentAccessToken();
                      Log.d(TAG, tok.getUserId());
                  }
  
                  @Override
                  public void onCancel()
                  {
                      Log.d(TAG, "On Cancel");
                  }
  
                  @Override
                  public void onError(FacebookException exception)
                  {
                      Log.e(TAG, exception.getMessage());
                  }
              });
  </code></pre>
  
  <p>I precise that the </p>
  
  <pre><code> Log.d(TAG, " Success"); 
  </code></pre>
  
  <p>doesn't print.</p>
  
  <p>There is only the first log who print something, outside the callback.</p>
  
  <p>Sorry for the bad English. </p>