Twitter Login integration in Android

Updated 31 December 2016

Save

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.

author
. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


1 comments

  • Shubham Agarwal
  • Start a Project


      Message Sent!

      If you have more details or questions, you can reply to the received confirmation email.

      Back to Home