Twitter Login integration in Android

Login through social networking sites in different mobile application is a great idea as it provides an easy and fast access to the customer. Through social login, customers can by-pass the long form filling process and also they don’t have to set and remember the password. Also for application owners its a secure and fast way to check the authenticity of the customer.

So here today we will integrate twitter login in a demo mobile application.Please follow the below mentioned steps:

  1. You have to login to your fabric account (if you don’t have an account create one here).
  2. Now go to twitter application site and loginĀ  with your twitter account to create the application.
  3. Create a new Application here by filling the form and after that you will get the TWITTER KEY and TWITTER SECRET. screenshot_1screenshot_2

With that your application is registered with twitter.

Integrating Twitter in Android Studio:

The integration is quiet simpler in Android Studio as you only have to play with tools and everything else will be done without any effort.

  1. You have to install fabric to Android Studio. For this Go to Settings>Plug-in and in search bar search for fabric. After installation it may ask for restart.screenshot_3
  2. Then go to fabric plugin and click the power button. After that select your project and then In Kits go for Twitter.screenshot_4screenshot_5
  3. Install twitter and login with the twitter key and secret. It will show you the changes it will make to your code, just go for apply (you can see what are the changes and then only go for apply). It will build and run the app once for you.

As of now twitter is integrated in our project. Lets move to the next section.

Applying twitter login in your login activity:

Add the Twitter Button to your login XML

In Login Activity add the following code:

On success you will get a Twitter Session that will provide you all the client details. Also add onActivityResult() as

Thats all and your twitter login is done for more info check our fabric docs.

. . .

Comment (1)

Add Your Comment

  • Shubham Agarwal
    works perfectly. Thanks
  • css.php
    Hire Us!
    Brief us about your requirements and we'll get back to you.
    Woo! Hooy!
    We have just recieved your project brief and our expert will contact you shortly.
    Send Again
    Close