title: Android: Add users to Parse via Facebook, using its `ParseFacebookUtils`
body: <p>I have downloaded the sample from Parse.com for its login using facebook and adding uers to its data browser.
  Its code is as follows:</p>
  
  <h2>IntegratingFacebookTutorialApplication class</h2>
  
  <pre><code>public class IntegratingFacebookTutorialApplication extends Application {
  
      static final String TAG = "MyApp";
  
      @Override
      public void onCreate() {
          super.onCreate();
  
          Parse.initialize(this, "Parse Application ID",
                  "Parse Client Key");
  
          ParseFacebookUtils.initialize(getString(R.string.facebook_app_id));
  
      }
  </code></pre>
  
  <h2>Login class</h2>
  
  <pre><code>import java.util.Arrays;
  import java.util.List;
  import android.app.Activity;
  import android.app.Dialog;
  import android.app.ProgressDialog;
  import android.content.Intent;
  import android.os.Bundle;
  import android.util.Log;
  import android.view.Menu;
  import android.view.View;
  import android.widget.Button;
  import android.widget.Toast;
  
  import com.parse.LogInCallback;
  import com.parse.ParseException;
  import com.parse.ParseFacebookUtils;
  import com.parse.ParseUser;
  
  public class LoginActivity extends Activity {
  
      private Button loginButton;
      private Dialog progressDialog;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
          setContentView(R.layout.main);
  
          loginButton = (Button) findViewById(R.id.loginButton);
          loginButton.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  onLoginButtonClicked();
              }
          });
  
          // Check if there is a currently logged in user
          // and they are linked to a Facebook account.
          ParseUser currentUser = ParseUser.getCurrentUser();
          if ((currentUser != null) &amp;&amp; ParseFacebookUtils.isLinked(currentUser)) {
              // Go to the user info activity
              showUserDetailsActivity();
          }
      }
  
      @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;
      }
  
      @Override
      public void onActivityResult(int requestCode, int resultCode, Intent data) {
          super.onActivityResult(requestCode, resultCode, data);
          ParseFacebookUtils.finishAuthentication(requestCode, resultCode, data);
      }
  
      private void onLoginButtonClicked() {
          LoginActivity.this.progressDialog = ProgressDialog.show(
                  LoginActivity.this, "", "Logging in...", true);
          List&lt;String&gt; permissions = Arrays.asList("basic_info", "user_about_me",
                  "user_relationships", "user_birthday", "user_location");
          ParseFacebookUtils.logIn(permissions, this, new LogInCallback() {
              @Override
              public void done(ParseUser user, ParseException err) {
                  LoginActivity.this.progressDialog.dismiss();
                  if (user == null) 
                  {
                      Toast.makeText(getApplicationContext(), "Uh oh. The user cancelled the Facebook login.",
                               Toast.LENGTH_SHORT).show();
  
                  } else if (user.isNew()) {
                      Toast.makeText(getApplicationContext(), "User signed up and logged in through Facebook.",
                               Toast.LENGTH_SHORT).show();
  
  
                      showUserDetailsActivity();
                  } else {
                      Toast.makeText(getApplicationContext(), "User logged in through Facebook!",
                               Toast.LENGTH_SHORT).show();
  
  
                      showUserDetailsActivity();
                  }
              }
          });
      }
  
      private void showUserDetailsActivity() {
          Intent intent = new Intent(this, UserDetailsActivity.class);
          startActivity(intent);
      }
  
  }
  </code></pre>
  
  <h2>Question:</h2>
  
  <p>Starting up the app (this tutorial), login page (page A) is shown, with a login in facebook button in middle.</p>
  
  <p>If a user does not have facebook app in his device, the above code can run smoothly and successfully, after pressing login button, it will pop a dialog box and after logged in, the user details can be fetched and user details added to the data browser inside Parse.</p>
  
  <p>However, if the user has already installed facebook app in the device, the dialog box would not appear, instead, it will open the facebook app and ask for login. This is where the problem happen. It shows for the permission dialog, and then after pressing "ok", the dialog is gone and return to the original page (page A).</p>
  
  <p>The toast remarks <code>"Uh oh. The user cancelled the Facebook login"</code>.</p>
  
  <p>What is wrong with the code?? or the ADT environment? Should I further add anything in manifest? </p>
  
  <p>I have researched as follows:</p>
  
  <ol>
  <li><p>some say 'After a lot of attempts, the trick was a support.jar, specifically android-support-v4.jar. This comes with the new latest Facebook SDK but is not standard on your project. Use the Facebook one that is in their SDK and copy it into your libs folder and link.' (<a href="https://parse.com/questions/urgent-parsefacebookutilslogin-issue-android">https://parse.com/questions/urgent-parsefacebookutilslogin-issue-android</a>)</p></li>
  <li><p>I was using the android:noHistory="true" on the manifest file for that activity. So whenever the facebook login activity was being opened, my activity was automatically being destroyed. But i do not have such history = true statement in the manifest.</p></li>
  </ol>