Updated 31 December 2016
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:
With that your application is registered with twitter.
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.
As of now twitter is integrated in our project. Lets move to the next section.
Add the Twitter Button to your login XML
1 2 3 4 |
<com.twitter.sdk.android.core.identity.TwitterLoginButton android:id="@+id/twitter_login_button" android:layout_width="wrap_content" android:layout_height="wrap_content" /> |
In Login Activity add the following code:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
TwitterLoginButton twitterButton; twitterButton = (TwitterLoginButton) findViewById(R.id.twitter_login_button); twitterButton.setCallback(new Callback<TwitterSession>() { @Override public void success(Result<TwitterSession> result) { //Success } @Override public void failure(TwitterException exception) { // Failed } }); |
On success you will get a Twitter Session that will provide you all the client details. Also add onActivityResult() as
1 2 3 4 5 |
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); twitterButton.onActivityResult(requestCode, resultCode, data); } |
Thats all and your twitter login is done for more info check our fabric docs.
If you have more details or questions, you can reply to the received confirmation email.
Back to Home
1 comments