Xutils 요청 서버 json 데이터

6514 단어
String code_url = "https://ic.snssdk.com/user/mobile/send_code/v2/";
                            HttpUtils httpUtils = new HttpUtils();
// RequestParams
params = new RequestParams(); params.addBodyParameter("type", "1");// params.addBodyParameter("mobile",shoujihao );//

httpUtils.send(HttpMethod.POST, code_url, params, new RequestCallBack<String>() { /* * (non-Javadoc) * * @see * com.lidroid.xutils.http.callback.RequestCallBack#onStart * () */ @Override public void onStart() { // TODO Auto-generated method stub super.onStart(); Log.i("TAG", " "); } @Override public void onFailure(HttpException arg0, String arg1) { Log.i("TAG", " : " + arg1); Toast.makeText(PhoneZhuCe.this, " : "+ arg1, 0).show(); } @Override public void onSuccess(ResponseInfo<String> arg0) { Log.i("TAG", " : " + arg0.result); String s=arg0.result;
Gson gson
=new Gson(); Loginphone fromJson = gson.fromJson(s, Loginphone.class); String message = fromJson.getMessage(); if(message.equals("success")){ Intent intent = new Intent(PhoneZhuCe.this, PhoneZhuCe2.class); startActivity(intent); }else{ Toast.makeText(PhoneZhuCe.this, fromJson.getData().getDescription(), 0) .show(); } } });

좋은 웹페이지 즐겨찾기