Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • How to Integrate Twitter Login for Your Android App in 6 Easy Steps

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 1
    • 0
    • 1.58k
    Comment on it

    Nowadays you must have seen while longing in many apps provides the login option directly using Facebook, Twitter, Linkedin and Google account, this process saves the time of filling a long registration form and also makes the user to login easily anytime. So, in this tutorial I had have explained about How You Can Integrating Twitter in Android.



    If you are willing to integrate Twitter login for your app then please go through the simple steps mentioned below and enjoy the power of code:


    Step 1) Add the dependencies to your project to enable twitter sdk

    you need to add the below line

    compile ''

    in your app's build.gradel(Module:app), after adding this sync your app.


    Step 2) Now go to twitter app dashboard and create a new app below is the link for the same, this will be generating CONSUMER_KEY and CONSUMER_SECRET that will be used within your app for authentication


    Step 3) Now add CONSUMER_KEY and CONSUMER_SECRET in your string.xml file as shown below

    <string name=""> 7Ua1fRWsqpecLDCSUsyp3JkpG</string>
        <string name=""> ue7JIHeVVtk56gX3yDXGMpWAqpxGSJjfpTibOyp6kyhA1LNYLf</string>


    Step 4) Now initialize Twitter kit by using the line


    in your Activities onCreate method.


    Step 5) Now add a Twitter login button in your activities layout (xml) file as shown here

            android:layout_height="wrap_content" />


    Step 6) Now add the code given below in your corresponding activity to handle the functioning of twitter login Button

    public class LoginActivity extends AppCompatActivity {
        TwitterLoginButton loginButton;
        protected void onCreate(Bundle savedInstanceState) {
            loginButton = (TwitterLoginButton) findViewById(;
            loginButton.setCallback(new Callback<TwitterSession>() {
                public void success(Result<TwitterSession> result) {
                    Toast.makeText(LoginActivity.this, "Logged in successFully", Toast.LENGTH_SHORT).show();
                    // Do something with result, which provides a TwitterSession for making API calls
                public void failure(TwitterException exception) {
                    // Do something on failure
        protected void onActivityResult(int requestCode, int resultCode, Intent data) {
            super.onActivityResult(requestCode, resultCode, data);
            // Pass the activity result to the login button.
            loginButton.onActivityResult(requestCode, resultCode, data);


    That's all, You have integrated Twitter to your app. If you have any questions or feedback, please feel free to write in comments below.

    How to Integrate Twitter Login for Your Android App in 6 Easy Steps

 0 Comment(s)

Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: