title: Facebook on Android without using fragments
body: <p>I would like to implement a complete management of the basic things about facebook on an app, so requesting personal information, friend list and posting on the wall. All of this should be done without the use of fragments, using API 3.0.</p>
  
  <p>Right now I'm stuck on the only example I have got that makes this, that is SessionLoginSampleActivity. My program right now is nothing more than that example, adapted on my layout, you can find it on the end of the post.
  Unfortunately that example does not go beyond authentication, and I cannot realize how to make asynchronous talk with facebook and retrieve user data and all that stuff.</p>
  
  <p>Is there a <em>complete</em> example somewhere that does it?</p>
  
  <p>After the authentication, how can I asynchronously retrieve my user picture, my name and my friend list, without fragments? Where should I write it? Should I create a new listener?</p>
  
  <p>The question may appear weird and basic, but I'm really getting crazy with the facebook API that looks so powerful and yet very very obscure to my eyes.</p>
  
  <p>Please don't answer me: "use fragments!" :)</p>
  
  <p>Thank you very much!</p>
  
  <pre><code>public class FbActivity extends Activity {
  private Button buttonLoginLogout, b_friends, b_challenge;
  private TextView t_instructions, t_username;
  private ProfilePictureView profilePictureView;
  private Session.StatusCallback statusCallback = new SessionStatusCallback();
  
  public FbActivity() {
  }
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.facebook_activity);
      findAll();
  
      Settings.addLoggingBehavior(LoggingBehavior.INCLUDE_ACCESS_TOKENS);
  
      Session session = Session.getActiveSession();
      if (session == null) {
          if (savedInstanceState != null) {
              session = Session.restoreSession(this, null, statusCallback, savedInstanceState);
          }
          if (session == null) {
              session = new Session(this);
          }
          Session.setActiveSession(session);
          if (session.getState().equals(SessionState.CREATED_TOKEN_LOADED)) {
              session.openForRead(new Session.OpenRequest(this).setCallback(statusCallback));
          }
      }
  
      updateView();
  }
  @Override
  public void onStart() {
      super.onStart();
      Session.getActiveSession().addCallback(statusCallback);
  }
  @Override
  public void onStop() {
      super.onStop();
      Session.getActiveSession().removeCallback(statusCallback);
  }
  @Override
  public void onActivityResult(int requestCode, int resultCode, Intent data) {
      super.onActivityResult(requestCode, resultCode, data);
      Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data);
  }
  @Override
  protected void onSaveInstanceState(Bundle outState) {
      super.onSaveInstanceState(outState);
      Session session = Session.getActiveSession();
      Session.saveSession(session, outState);
  }
  
  private void findAll() {
      buttonLoginLogout = (Button)findViewById(R.id.buttonLoginLogout);
      t_instructions = (TextView)findViewById(R.id.instructionsOrLink);
      b_friends = (Button)findViewById(R.id.buttonFindFriend);
      b_challenge = (Button)findViewById(R.id.buttonFindNewChallenge);
      profilePictureView = (ProfilePictureView)findViewById(R.id.profilePicture);
      t_username = (TextView)findViewById(R.id.textViewUserName);
  }
  
  
  
  private void setVisibility(boolean opened) {
      if (opened) {
          buttonLoginLogout.setText(R.string.logout);
          buttonLoginLogout.setOnClickListener(new OnClickListener() {
              public void onClick(View view) { onClickLogout(); }
          });
          t_instructions.setVisibility(TextView.INVISIBLE);
          b_friends.setVisibility(Button.VISIBLE);
          b_challenge.setVisibility(Button.VISIBLE);
          t_username.setVisibility(TextView.VISIBLE);
          profilePictureView.setVisibility(ProfilePictureView.VISIBLE);
      } else {
          buttonLoginLogout.setText(R.string.login);
          buttonLoginLogout.setOnClickListener(new OnClickListener() {
              public void onClick(View view) { onClickLogin(); }
          });
          t_instructions.setVisibility(TextView.VISIBLE);
          b_friends.setVisibility(Button.INVISIBLE);
          b_challenge.setVisibility(Button.INVISIBLE);
          t_username.setVisibility(TextView.VISIBLE);
          profilePictureView.setVisibility(ProfilePictureView.INVISIBLE);
      }
  
  }
  private void updateView() {
      Session session = Session.getActiveSession();
      setVisibility(session.isOpened());
  }
  
  private void onClickLogin() {
      Session session = Session.getActiveSession();
      if (!session.isOpened() &amp;&amp; !session.isClosed()) {
          session.openForRead(new Session.OpenRequest(this).setCallback(statusCallback));
      } else {
          Session.openActiveSession(this, true, statusCallback);
      }
  }
  private void onClickLogout() {
      Session session = Session.getActiveSession();
      if (!session.isClosed()) {
          session.closeAndClearTokenInformation();
      }
  }   
  private class SessionStatusCallback implements Session.StatusCallback {
      @Override
      public void call(Session session, SessionState state, Exception exception) {
          updateView();
      }
  }
  
  }
  </code></pre>