Search in sources :

Example 1 with JsonHttpResponseHandler

use of com.juns.health.net.loopj.android.http.JsonHttpResponseHandler in project wechat by motianhuo.

the class RegisterActivity method getCode.

private void getCode() {
    String phone = et_usertel.getText().toString();
    RequestParams params = new RequestParams();
    params.put("telephone", phone);
    params.put("codeType", "1");
    netClient.post(Constants.SendCodeURL, params, new JsonHttpResponseHandler() {

        @Override
        public void onSuccess(JSONObject response) {
            super.onSuccess(response);
            try {
                String result = response.getString("result");
                System.out.println("返回的值" + response);
                if (result == null) {
                    Utils.showLongToast(App.getInstance(), Constants.NET_ERROR);
                } else if (result.equals("Y")) {
                    String str = response.getString("value");
                    Utils.showLongToast(App.getInstance(), str);
                } else {
                    String str = response.getString("value");
                    Utils.showLongToast(App.getInstance(), str);
                    mc.cancel();
                    btn_send.setEnabled(true);
                    btn_send.setText("发送验证码");
                }
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    });
}
Also used : JSONObject(org.json.JSONObject) JSONException(org.json.JSONException) JsonHttpResponseHandler(com.juns.health.net.loopj.android.http.JsonHttpResponseHandler) RequestParams(com.juns.health.net.loopj.android.http.RequestParams)

Aggregations

JsonHttpResponseHandler (com.juns.health.net.loopj.android.http.JsonHttpResponseHandler)1 RequestParams (com.juns.health.net.loopj.android.http.RequestParams)1 JSONException (org.json.JSONException)1 JSONObject (org.json.JSONObject)1