-1
我正在創建登錄和註冊頁面,'m正在面臨問題,json結果取零值...我檢查了fulll代碼,但是在此htpclient ,是的HttpParams有重拳出擊線對他們請修復已棄用Httpclient,httpResponse在android studio 1.5.1中被拒絕
private class AsyncDataClass extends AsyncTask<String, Void, String > {
@Override
protected String doInBackground(String... params) {
HttpParams httpParameters = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(httpParameters, 5000);
HttpConnectionParams.setSoTimeout(httpParameters, 5000);
HttpClient httpClient = new DefaultHttpClient(httpParameters);
HttpPost httpPost = new HttpPost(params[0]);
String jsonResult = "";
try {
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("name", params[1]));
nameValuePairs.add(new BasicNameValuePair("phoneno", params[2]));
nameValuePairs.add(new BasicNameValuePair("emailid", params[3]));
nameValuePairs.add(new BasicNameValuePair("password", params[4]));
httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpClient.execute(httpPost);
jsonResult = inputStreamToString(response.getEntity().getContent()).toString();
System.out.println("Returned Json object " + jsonResult.toString());
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return jsonResult;