title: Facebook Android SDK 3.0 Login Button does not save my session
body: <p>I'm trying Facebook Android SDK 3.0 tutorial but I'm facing a problem. When I clicked the login button and logged in using my facebook account, im expecting to see my button's text to change to logout as what the tutorial (<a href="http://developers.facebook.com/docs/howtos/androidsdk/3.0/login-with-facebook/" rel="nofollow noreferrer">http://developers.facebook.com/docs/howtos/androidsdk/3.0/login-with-facebook/</a>) states but it did not happen. I added log to see if it passes by onActivityResult as suggested by <a href="https://stackoverflow.com/questions/14260555/facebook-android-sdk-3-0-always-returns-opening-when-logging-in">this</a> question. Here's my log:</p>
  
  <pre><code>MainFragment   Unknown State: OPENING
  MainFragment   onActivityResult
  MainFragment   Logged out...
  </code></pre>
  
  <p>Please help. I don't know where did I get wrong and what to do next?</p>
  
  <p><strong>MainFragment.java</strong></p>
  
  <pre><code>public class MainFragment extends Fragment{
  
      private static final String TAG = "MainFragment";
      private UiLifecycleHelper uiHelper;
      private Session.StatusCallback callback = new Session.StatusCallback() {
          @Override
          public void call(Session session, SessionState state, Exception exception) {
              onSessionStateChange(session, state, exception);
          }
      };
  
      private void onSessionStateChange(Session session, SessionState state, Exception exception) {
          if (state.isOpened()) {
              Log.i(TAG, "Logged in...");
          } else if (state.isClosed()) {
              Log.i(TAG, "Logged out...");     
          } else {
              Log.d(TAG, "Unknown state: " + state);
          }
      }
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          uiHelper = new UiLifecycleHelper(getActivity(), callback);
          uiHelper.onCreate(savedInstanceState);
      }
  
      @Override
      public void onResume() {
          super.onResume();
  
          // For scenarios where the main activity is launched and user
          // session is not null, the session state change notification
          // may not be triggered. Trigger it if it's open/closed.
          Session session = Session.getActiveSession();
          if (session != null &amp;&amp; (session.isOpened() || session.isClosed()) ) {
              onSessionStateChange(session, session.getState(), null);
          }
  
          uiHelper.onResume();
      }
  
      @Override
      public void onActivityResult(int requestCode, int resultCode, Intent data) {
          super.onActivityResult(requestCode, resultCode, data);
          uiHelper.onActivityResult(requestCode, resultCode, data);
          Log.d(TAG, "onActivityResult");
      }
  
      @Override
      public void onPause() {
          super.onPause();
          uiHelper.onPause();
      }
  
      @Override
      public void onDestroy() {
          super.onDestroy();
          uiHelper.onDestroy();
      }
  
      @Override
      public void onSaveInstanceState(Bundle outState) {
          super.onSaveInstanceState(outState);
          uiHelper.onSaveInstanceState(outState);
      }   
  
      @Override
      public View onCreateView(LayoutInflater inflater,
              ViewGroup container, 
              Bundle savedInstanceState) {
          View view = inflater.inflate(R.layout.main, container, false);      
  
          LoginButton authButton = (LoginButton) view.findViewById(R.id.authButton);
          authButton.setFragment(this);    
  
          return view;
      }
  }
  </code></pre>
  
  <p><strong>MainActivity.java</strong></p>
  
  <pre><code>public class MainActivity extends FragmentActivity {
  
      private MainFragment mainFragment;
      private static final String TAG = "MainActivity";
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
          if (savedInstanceState == null) {
              // Add the fragment on initial activity setup
              mainFragment = new MainFragment();
              getSupportFragmentManager()
              .beginTransaction()
              .add(android.R.id.content, mainFragment)
              .commit();
          } else {
              // Or set the fragment from restored state info
              mainFragment = (MainFragment) getSupportFragmentManager()
              .findFragmentById(android.R.id.content);
          }
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.main, menu);
          return true;
      }
  
  }
  </code></pre>
  
  <p><strong>main.xml</strong></p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical"&gt;
  
      &lt;com.facebook.widget.LoginButton
          android:id="@+id/authButton"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_gravity="center_horizontal"
          android:layout_marginTop="30dp"
      /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>