Example usage for twitter4j TwitterMethod OAUTH_REQUEST_TOKEN

List of usage examples for twitter4j TwitterMethod OAUTH_REQUEST_TOKEN

Introduction

In this page you can find the example usage for twitter4j TwitterMethod OAUTH_REQUEST_TOKEN.

Prototype

TwitterMethod OAUTH_REQUEST_TOKEN

To view the source code for twitter4j TwitterMethod OAUTH_REQUEST_TOKEN.

Click Source Link

Usage

From source file:com.marpies.ane.twitter.LoginActivity.java

License:Apache License

/**
 *
 *
 * Private API// www .ja  va2  s  .co  m
 *
 *
 */

private TwitterAdapter getOAuthRequestTokenListener(final boolean forceLogin) {
    return new TwitterAdapter() {
        @Override
        public void gotOAuthRequestToken(RequestToken token) {
            TwitterAPI.setRequestToken(token);
            StringBuilder urlBuilder = new StringBuilder(token.getAuthenticationURL());
            if (forceLogin) {
                urlBuilder.append("&force_login=true");
            }
            /* Launch browser */
            LoginActivity.this.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(urlBuilder.toString())));
        }

        @Override
        public void onException(TwitterException te, TwitterMethod method) {
            if (method == TwitterMethod.OAUTH_REQUEST_TOKEN) {
                AIR.log("Request token exception " + te.getMessage());
                AIR.dispatchEvent(AIRTwitterEvent.LOGIN_ERROR, StringUtils.removeLineBreaks(te.getMessage()));
            }
            finish();
        }
    };
}