title: Facebook SDK 3.0 - Tutorial
body: <p>Hey can someone point me in the right direction of a good Facebook tutorial for android?  The tutorial their developer site isnt all that good.</p>
  
  <p>This is what i've came up with so far:</p>
  
  <pre><code>public static final int FBResultCode = 100;
  private static Session.StatusCallback sharedFBStatusCallback = new Session.StatusCallback()
  {
      @Override
      public void call(Session session, SessionState state, Exception exception)
      {
          if(exception != null)
              Log.e("fb error", exception.toString());
          switch(state)
          {
          case OPENED:
                              //login successful
              break;
          case CLOSED:
          case CLOSED_LOGIN_FAILED:
              closeFBSession();
              break;
          default:
              break;
          }
      }
  };
  
  public static void openFBSessionWithLoginUI(boolean loginUI)
  {
      Session session = Session.getActiveSession();
  
      if (session != null &amp;&amp; 
              !session.isOpened() &amp;&amp; 
              !session.isClosed()) 
      {
          ArrayList&lt;String&gt; perms = new ArrayList&lt;String&gt;();
          perms.add("user_likes");
          perms.add("user_birthday");
          perms.add("read_friendlists");
  
          Session.OpenRequest openRequest = new Session.OpenRequest(rootActivity)
          .setCallback(sharedFBStatusCallback)
          .setDefaultAudience(SessionDefaultAudience.FRIENDS)
          .setLoginBehavior(loginUI? SessionLoginBehavior.SUPPRESS_SSO: SessionLoginBehavior.SSO_ONLY)
          .setRequestCode(FBResultCode)
          .setPermissions(perms);
  
          session.openForRead(openRequest);
      }
      else 
      {
          Session.openActiveSession(rootActivity, loginUI, sharedFBStatusCallback);
      }
  
  }
  
  private static void closeFBSession()
  {
      Session currentSess = Session.getActiveSession();
  
      if(currentSess != null)
      {
          currentSess.closeAndClearTokenInformation();
      }
  }
  </code></pre>
  
  <p>However this returns an error:</p>
  
  <blockquote>
    <p>E/fb error(3601): java.lang.UnsupportedOperationException: Session:
    an attempt was made to open a session that has a pending request.</p>
  </blockquote>
  
  <p>What am i doing wrong? Or better yet, what is the best way to handle fb logins?</p>