Beispiel #1
0
    @Override
    protected DBResult doInBackground(String... params) {

      String token = params[0];
      long expiresInSeconds = Long.valueOf(params[1]);

      try {
        UserBean user = new OAuthDao(token).getOAuthUserInfo();
        AccountBean account = new AccountBean();
        account.setAccess_token(token);
        account.setExpires_time(System.currentTimeMillis() + expiresInSeconds * 1000);
        account.setInfo(user);
        AppLogger.e("token expires in " + Utility.calcTokenExpiresInDays(account) + " days");
        return AccountDBTask.addOrUpdateAccount(account, false);
      } catch (WeiboException e) {
        AppLogger.e(e.getError());
        this.e = e;
        cancel(true);
        return null;
      }
    }
 @Override
 protected String doInBackground(Void... params) {
   try {
     String token =
         new BMOAuthDao(
                 username.getText().toString(), password.getText().toString(), appkey, appSecret)
             .login();
     UserBean user = new OAuthDao(token).getOAuthUserInfo();
     AccountBean account = new AccountBean();
     account.setAccess_token(token);
     account.setUsername(user.getName());
     account.setUid(user.getId());
     account.setUsernick(user.getScreen_name());
     account.setAvatar_url(user.getProfile_image_url());
     account.setInfo(user);
     DatabaseManager.getInstance().addOrUpdateAccount(account);
     return token;
   } catch (WeiboException e) {
     this.e = e;
     cancel(true);
   }
   return "";
 }