コード例 #1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    TwitterAuthConfig authConfig = new TwitterAuthConfig(TWITTER_KEY, TWITTER_SECRET);
    Fabric.with(this, new Twitter(authConfig));
    TwitterSession session = Twitter.getInstance().core.getSessionManager().getActiveSession();

    if (session != null) {
      Twitter4JFactory.generateInstance(
          TWITTER_KEY, TWITTER_SECRET, session.getAuthToken().token, session.getAuthToken().secret);
      Twitter.getApiClient(session)
          .getAccountService()
          .verifyCredentials(
              false,
              true,
              new com.twitter.sdk.android.core.Callback<User>() {

                Intent intent = new Intent(LoginActivity.this, MainActivity.class);

                @Override
                public void success(Result<User> result) {
                  startActivity(intent);
                  finish();
                }

                @Override
                public void failure(TwitterException e) {
                  loadLoginScreen();
                  // Continues execution
                }
              });
    } else {
      loadLoginScreen();
    }
  }
コード例 #2
0
 @ReactMethod
 public String getCurrentToken(final Callback callback) {
   TwitterSession session = Twitter.getSessionManager().getActiveSession();
   if (session != null) {
     TwitterAuthToken authToken = session.getAuthToken();
     String token = authToken.token;
     String secret = authToken.secret;
     if (callback != null) {
       callback.invoke(token);
     }
     return token;
   }
   if (callback != null) {
     callback.invoke(null);
   }
   return null;
 }
コード例 #3
0
 public ClientUserTable(TwitterSession twitterSession) {
   userId = twitterSession.getUserId();
   userName = twitterSession.getUserName();
   authToken = twitterSession.getAuthToken().token;
   authTokenSecret = twitterSession.getAuthToken().secret;
 }