@Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.oauthv1);

    oAuth = new OAuthV1(oauthCallback);
    oAuth.setOauthConsumerKey(oauthConsumeKey);
    oAuth.setOauthConsumerSecret(oauthConsumerSecret);

    // 设置界面元素,并添加对各按钮的监听
    btnRequest = (Button) findViewById(R.id.btnRequest);
    textRequest = (TextView) findViewById(R.id.textRequest);
    btnAuthorize = (Button) findViewById(R.id.btnAuthorize);
    textVerifier = (TextView) findViewById(R.id.textVerifier);
    btnAccess = (Button) findViewById(R.id.btnAccess);
    textAccess = (TextView) findViewById(R.id.textAccess);
    btnAPItest = (Button) findViewById(R.id.btnAPItest);
    btnRequest.setOnClickListener(listener);
    btnAuthorize.setOnClickListener(listener);
    btnAccess.setOnClickListener(listener);
    btnAPItest.setOnClickListener(listener);

    // 关闭OAuthV1Client中的默认开启的QHttpClient。
    OAuthV1Client.getQHttpClient().shutdownConnection();

    // 为OAuthV1Client配置自己定义QHttpClient。
    OAuthV1Client.setQHttpClient(new QHttpClient());
  }
示例#2
0
 public OAuthV1 getOAuthV1() throws Exception {
   OAuthV1 oAuth = new OAuthV1("null");
   oAuth.setOauthConsumerKey(APP_KEY);
   oAuth.setOauthConsumerSecret(APP_SECRET);
   oAuth = OAuthV1Client.requestToken(oAuth);
   return oAuth;
 }