title: Custom facebook login button in android studio
body: <p>In my android app, I've integrated facebook login which is working fine. Later, I've customized the login button which is also working without any problem. When the user clicks on facebook login button, it successfully let the user logged in without any problem. But the problem is, when user logged in, instead of going to next activity it displays the same login page with facebook button with logout text on facebook login button and then goes to next activity. See the image below:
  <img src="https://i.stack.imgur.com/FnMHl.png" alt="enter image description here"></p>
  
  <p>This is customized facebook login button which is working fine.<strong>See the image below after log in:</strong>
  <img src="https://i.stack.imgur.com/p11xi.png" alt="enter image description here"></p>
  
  <p>It displays Logout text on button and then it goes to next activity. I want to go directly to next activity instead of displaying this login button with Logout text. How do I do this.? Any help..!!<br>
  Here is my code below:</p>
  
  <p><strong>xml code :</strong></p>
  
  <pre><code>&lt;com.facebook.login.widget.LoginButton
          xmlns:fb="http://schemas.android.com/apk/res-auto"
          android:id="@+id/login_button"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          fb:login_text=""
          android:layout_gravity="center"/&gt;
  </code></pre>
  
  <p><strong>MainActivity.java</strong></p>
  
  <pre><code>loginButton = (LoginButton)findViewById(R.id.login_button);
          loginButton.setBackgroundResource(R.drawable.fb);
          loginButton.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
          loginButton.setCompoundDrawablePadding(0);
          loginButton.setPadding(0, 0, 0, 0);
          loginButton.setText("");
          loginButton.setReadPermissions(permissionNeeds);
  
  loginButton.registerCallback(callbackManager,new FacebookCallback&lt;LoginResult&gt;()
          {
              @Override
              public void onSuccess(LoginResult loginResult)
              {
                  GraphRequest request = GraphRequest.newMeRequest(AccessToken.getCurrentAccessToken(),
                      new GraphRequest.GraphJSONObjectCallback()
                      {
                          @Override
                          public void onCompleted(JSONObject user, GraphResponse response)
                          {
                              if(user !=null)
                              {
                                  String firstName = user.optString("first_name");
                                  String lastName = user.optString("last_name");
                                  String email = user.optString("email");
  
                                  Intent i1 = new Intent(getApplicationContext(),FacebookData.class);
                                  i1.putExtra("first",firstName);
                                  i1.putExtra("last",lastName);
                                  i1.putExtra("email",email);
                                  startActivity(i1);
                              }
                          }
                      });
                      Bundle parameters = new Bundle();
                      parameters.putString("fields", "id,first_name,last_name,email");
                      request.setParameters(parameters);
                      request.executeAsync();
                  }
  </code></pre>