TwitterSignIn is a library which makes signin easier. Library is still in development so more features will be added soon.
Features:
- Twitter SignIn
- Fetch User Details(ID, Name)
Getting started:
- First of all, you need to register you application with twitter developer (https://apps.twitter.com) and don't enable email checkbox in twitter developer account.
- Add twitterlibrary into your project as module.
- Add below line under dependencies{..} tag of app.gradle of your project
compile project(path: ':twitterlibrary') - How to call library function from your activity or fragment Declare this global in activity - private TwitterSignInAI mTwitterSignInAI;
- Call initializeTwitter method from onCreate method
private void initializeTwitter() { mTwitterSignInAI = new TwitterSignInAI(); mTwitterSignInAI.setActivity(MainActivity.this); mTwitterSignInAI.setCallback(this); }
after this you can call doSignIn method using mTwitterSignInAI.
- Implement TwitterSignCallback in your activity or fragment.
- Add below code into onActivityResultMethod
mTwitterSignInAI.setActivityResult(requestCode, resultCode, data);
How to parse result data
public void twitterSignInSuccessResult(Result<TwitterSession> twitterSessionResult) {
String name = twitterSessionResult.data.getUserName();
String id = String.valueOf(twitterSessionResult.data.getId());
((TextView)findViewById(R.id.tv_id)).setText("Id: "+id);
((TextView)findViewById(R.id.tv_name)).setText("Name: "+name);
}
Releases
- Version 1.1 - 3 Nov 2017
End Authorize Progress (Twitter Sign in at two places - Handling of unauthorized access) - Version 1.2 - 12 March 2018
Resolve context issue