Q:

How to handle Twitter and facebook request code

How to handle Twitter and facebook request code On ActivityResult.
  @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

       // If request code of facebook than i will call other function and if
       // request code of twitter than i will call some other function but 
       // how i can  seprate both by request code.

}

A:

As of com.twitter.sdk.android:twitter:1.14.1 you can use:
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == TwitterAuthConfig.DEFAULT_AUTH_REQUEST_CODE) {
        // Twitter request code
        // TwitterLoginButton::onActivityResult(requestCode::int, resultCode::int, data::Intent);
    } else {
        // Use Facebook callback manager here
        // CallbackManager::onActivityResult(requestCode::int, resultCode::int, data::Intent);
    }
}

A:

You Have 2 options :
1) On click of fb or twitter button, set a Boolean value to true and check which button was clicked to determine the method you want to call. 
   @Override
   protected void onActivityResult(int requestCode, int resultCode, Intent data) {
     super.onActivityResult(requestCode, resultCode, data);

  if (fb_clicked == true)
 {
     //call the callback manager's onActivityResult
 }
 else if(twitter_clicked == true)
{
     //call the twitter login button's onActivityResult
}
}

2) Or you can Use the Auth Token to determine which button was clicked as the auth token will be generated when you click on the LoginButton (twitter or facebook and the other should be null)
   @Override
   protected void onActivityResult(int requestCode, int resultCode, Intent data) {
     super.onActivityResult(requestCode, resultCode, data);

     if (requestCode == TwitterAuthConfig.DEFAULT_AUTH_REQUEST_CODE) {
    // Twitter request code
    // TwitterLoginButton::onActivityResult(requestCode::int, resultCode::int, data::Intent);
} else {
    // Use Facebook callback manager here
    // CallbackManager::onActivityResult(requestCode::int, resultCode::int, data::Intent);
}
}

EDIT : Updated the code with Patrick W's answer for the 2nd option, which is a much better approach and as he mentions this solution works for com.twitter.sdk.android:twitter:1.14.1 and above.

