Exemple #1
0
  /**
   * 登录
   *
   * @since 2014-02-28
   */
  public void login() {
    if (!tencent.isSessionValid()) {
      tencent.login(
          (Activity) context,
          SCOPE,
          new BaseUIListener() {

            @Override
            protected void doComplete(JSONObject obj) {
              TencentQQToken token = new TencentQQToken();
              try {
                token.setOpenid(obj.getString("openid"));
                token.setAccess_token(obj.getString("access_token"));
                token.setExpires_in(obj.getString("expires_in"));
              } catch (JSONException e) {
                e.printStackTrace();
              }

              QQTokenKeeper.writeAccessToken(context, token);
              userInfo = new UserInfo(context, tencent.getQQToken());
              getUserInfo();
            }
          });
    } else {
      tencent.logout(context);
    }
  }
 private void loginoutQQ() {
   Tencent mTencent = Tencent.createInstance(ConstantS.TENCENT_APP_ID, getApplicationContext());
   if (mTencent != null && mTencent.isSessionValid()) {
     try {
       mTencent.logout(context);
     } catch (Exception e) {
       // TODO: handle exception
     }
   }
 }
Exemple #3
0
 public void logoutQQ() {
   mTencent.logout(this);
 }