Android authorization twitter callback not called

I started using Twitter Fabric for Android. Logging in with TwitterLoginButton works fine, but in some cases I don't need to use TwitterLoginButton, I just need to get the user token and secret. The code looks right, the Twitter login form is open, 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 assume that I need to add some processing to onActivityResult, but this is not in the document https://dev.twitter.com/twitter-kit/android/request-email

+5
source share
1 answer

You are correct that you need to add some processing to onActivityResult in order to receive a callback. To pass the result of the activity 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 TwitterLoginButton does in its TwitterLoginButton#onActivityResult .

+13
source

Source: https://habr.com/ru/post/1208741/


All Articles