private static void failListener(int requestedAction, String message) {
    switch (requestedAction) {
      case ACTION_LOGIN:
        {
          RefLoginListener.fail("Login failed: " + message);
          break;
        }
      case ACTION_PUBLISH_STATUS:
        {
          RefSocialActionListener.fail("Publish status failed: " + message);
          break;
        }
      case ACTION_PUBLISH_STATUS_DIALOG:
        {
          RefSocialActionListener.fail("Publish status dialog failed: " + message);
          break;
        }
      case ACTION_PUBLISH_STORY:
        {
          RefSocialActionListener.fail("Publish story failed: " + message);
          break;
        }
      case ACTION_PUBLISH_STORY_DIALOG:
        {
          RefSocialActionListener.fail("Publish story dialog failed: " + message);
          break;
        }
      case ACTION_UPLOAD_IMAGE:
        {
          RefSocialActionListener.fail("Upload Image failed: " + message);
          break;
        }
      case ACTION_GET_FEED:
        {
          RefFeedListener.fail("Get feed failed: " + message);
          break;
        }
      case ACTION_GET_CONTACTS:
        {
          RefContactsListener.fail("Get contacts failed: " + message);
          break;
        }
      case ACTION_GET_USER_PROFILE:
        {
          RefUserProfileListener.fail("Get user profile failed: " + message);
          break;
        }
      default:
        {
          SoomlaUtils.LogWarning(TAG, "action unknown fail listener:" + requestedAction);
          break;
        }
    }

    clearListener(requestedAction);
  }
        /**
         * Called when OAuth authentication has been finalized and an Access Token and Access Token
         * Secret have been provided
         *
         * @param accessToken The access token to use to do REST calls
         */
        @Override
        public void gotOAuthAccessToken(AccessToken accessToken) {
          SoomlaUtils.LogDebug(TAG, "login/onComplete");

          twitter.setOAuthAccessToken(accessToken);

          // Keep in storage for logging in without web-authentication
          KeyValueStorage.setValue(
              getTwitterStorageKey(TWITTER_OAUTH_TOKEN), accessToken.getToken());
          KeyValueStorage.setValue(
              getTwitterStorageKey(TWITTER_OAUTH_SECRET), accessToken.getTokenSecret());

          // Keep screen name since Twitter4J does not have it when
          // logging in using authenticated tokens
          KeyValueStorage.setValue(
              getTwitterStorageKey(TWITTER_SCREEN_NAME), accessToken.getScreenName());

          twitterScreenName = accessToken.getScreenName();

          RefLoginListener.success(RefProvider);

          clearListener(ACTION_LOGIN);
        }
  /** {@inheritDoc} */
  @Override
  public void login(
      final Activity parentActivity, final AuthCallbacks.LoginListener loginListener) {
    if (!isInitialized) {
      SoomlaUtils.LogError(
          TAG, "Consumer key and secret were not defined, please provide them in initialization");
      return;
    }

    SoomlaUtils.LogDebug(TAG, "login");
    WeakRefParentActivity = new WeakReference<Activity>(parentActivity);

    RefProvider = getProvider();
    RefLoginListener = loginListener;

    preformingAction = ACTION_LOGIN;

    mainRequestToken = null;
    twitter.setOAuthAccessToken(null);

    // Try logging in using store credentials
    String oauthToken = KeyValueStorage.getValue(getTwitterStorageKey(TWITTER_OAUTH_TOKEN));
    String oauthTokenSecret = KeyValueStorage.getValue(getTwitterStorageKey(TWITTER_OAUTH_SECRET));
    if (!TextUtils.isEmpty(oauthToken) && !TextUtils.isEmpty(oauthTokenSecret)) {
      twitter.setOAuthAccessToken(new AccessToken(oauthToken, oauthTokenSecret));
      twitterScreenName = KeyValueStorage.getValue(getTwitterStorageKey(TWITTER_SCREEN_NAME));

      loginListener.success(RefProvider);

      clearListener(ACTION_LOGIN);
    } else {
      // If no stored credentials start login process by requesting
      // a request token
      twitter.getOAuthRequestTokenAsync(oauthCallbackURL);
    }
  }
 private static void cancelLogin() {
   if (RefLoginListener != null) {
     RefLoginListener.cancel();
     clearListener(ACTION_LOGIN);
   }
 }