(Android) Logging in programatically (not useing the TwitterLoginButton

android

#1

Hey guys, i have this code :

Twitter.logIn(getActivity(), new Callback<TwitterSession>() {
    @Override
    public void success(Result<TwitterSession> result) {
        Log.d("TWITTER", "TWITTER LOGIN SUCCESS : " + result.response.getReason());
    }

    @Override
    public void failure(TwitterException e) {
        Log.d("TWITTER", "FAIL ERROR: " + e.getMessage());
    }
}); 

I get the screen where it says, please authorize app. I click authorize, the window disappears and nothing happens.
Both of the logs(success and failure) dont appear either… how is that possible and what am i missing.
Thanks


#2

Did you get answer to your query?? I am facing similar issue.


#3

Hi @ssimeonss, @meenalbahua

It looks like the Twitter.logIn(...) method is broken and should be deprecated. The follow code should work around the issue.

public class LoginActivity extends Activity {
  TwitterAuthClient authClient;

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    authClient = new TwitterAuthClient();
    authClient.authorize(this, new Callback<TwitterSession>() {
        @Override
        public void success(Result<TwitterSession> result) {

        }

        @Override
        public void failure(TwitterException e) {

        }
    });
  }

  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    authClient.onActivityResult(requestCode, resultCode, data);
  }
}

#4

This topic was automatically closed after 24 hours. New replies are no longer allowed.