I have started using Twitter Fabric for Android. Login with TwitterLoginButton is working fine, but in some cases I don't need to use TwitterLoginButton, I just need to get user token and secret. The code looks right, twitter login form is opened but callback is called at all.
TwitterAuthClient authClient = new TwitterAuthClient();
authClient.authorize(TwitterSettingsActivity.this, new Callback<TwitterSession>() {
@Override
public void success(Result<TwitterSession> twitterSessionResult) {
Logger.e(TAG, "ok");
}
@Override
public void failure(TwitterException e) {
Logger.e(TAG, "failure error", e);
}
});
I guess I need to add some handling in onActivityResult but there is no info about it in the doc https://dev.twitter.com/twitter-kit/android/request-email
You're right that you need to add some handling in an onActivityResult to get the callback. To pass the Activity’s result back so that your callback receives it, you can do the following:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
// Pass the activity result to the auth client.
authClient.onActivityResult(requestCode, resultCode, data);
}
This is essentially what the TwitterLoginButton
is doing in its TwitterLoginButton#onActivityResult
method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With