Android 我正在使用列表<;配对<;字符串,字符串>&燃气轮机;但UrlEncodedFormEntity是一个使用namevaluepair的弃用类

Android 我正在使用列表<;配对<;字符串,字符串>&燃气轮机;但UrlEncodedFormEntity是一个使用namevaluepair的弃用类,android,http-post,Android,Http Post,这是我的jsonparser类,在该类中,我在httpPost.setEntity(新的UrlEncodedFormEntity(params))的参数中得到错误 公共类JSONParser{ 静态InputStream为空; 静态JSONObject jObj=null; 静态字符串json=“”; 公共JSONParser(){ } 公共JSONObject makeHttpRequest(字符串url、字符串方法、, 列表参数){ 试一试{ 如果(方法==“获取”){ DefaultHtt

这是我的jsonparser类,在该类中,我在httpPost.setEntity(新的UrlEncodedFormEntity(params))的参数中得到错误

公共类JSONParser{
静态InputStream为空;
静态JSONObject jObj=null;
静态字符串json=“”;
公共JSONParser(){
}
公共JSONObject makeHttpRequest(字符串url、字符串方法、,
列表参数){
试一试{
如果(方法==“获取”){
DefaultHttpClient httpClient=新的DefaultHttpClient();
HttpPost HttpPost=新的HttpPost(url);
setEntity(新的UrlEncodedFormEntity(参数));
HttpResponse HttpResponse=httpClient.execute(httpPost);
HttpEntity HttpEntity=httpResponse.getEntity();
is=httpEntity.getContent();
}else if(方法==“GET”){
DefaultHttpClient httpClient=新的DefaultHttpClient();
String paramString=URLEncodedUtils.format(params,“utf-8”);
url+=“?”+参数字符串;
HttpGet HttpGet=新的HttpGet(url);
HttpResponse HttpResponse=httpClient.execute(httpGet);
HttpEntity HttpEntity=httpResponse.getEntity();
is=httpEntity.getContent();
}
}捕获(IOE异常){
e、 printStackTrace();
}
试一试{
BufferedReader reader=新的BufferedReader(新的InputStreamReader(
为“UTF-8”)、8);
StringBuilder sb=新的StringBuilder();
字符串行=null;
而((line=reader.readLine())!=null){
sb.追加(第+行“\n”);
}
is.close();
json=sb.toString();
}捕获(例外e){
Log.e(“缓冲区错误”,“错误转换结果”+e.toString());
}
//尝试将字符串解析为JSON对象
试一试{
jObj=新的JSONObject(json);
}捕获(JSONException e){
Log.e(“JSON解析器”,“错误解析数据”+e.toString());
}
//返回JSON字符串
返回jObj;
}
}
这是我的UrlEncodedFormEntity类,它使用名称-值对

public class UrlEncodedFormEntity extends org.apache.http.entity.StringEntity         
{
   public UrlEncodedFormEntity(java.util.List<? extends 
   org.apache.http.NameValuePair> parameters, java.lang.String encoding) 
   throws java.io.UnsupportedEncodingException { /* compiled code */ }

   public UrlEncodedFormEntity(java.util.List<? extends 
   org.apache.http.NameValuePair> parameters) throws 
   java.io.UnsupportedEncodingException { /* compiled code */ }
}
公共类UrlEncodedFormEntity扩展org.apache.http.entity.StringEntity
{

public UrlEncodedFormEntity(java.util.ListWhat error?清楚地解释您的问题、您迄今为止尝试了什么以及为什么它不起作用。专业发布提示:无需添加“您好”、“请帮助我”和“提前感谢”在你的问题中的任何地方,特别是在标题中,细节和简洁是首选。希望这能有所帮助!我试图在JSONParser类中使用List而不是List,但由于UrlEncodedFormEntity类,它在httpPost.setEntity(新的UrlEncodedFormEntity(params))行中给出了错误;我不知道如何解决什么错误?清楚地解释你的问题、你迄今为止尝试了什么以及为什么它不起作用。专业发帖提示:没有必要添加“嗨”、“请帮助我”和“提前感谢”在你的问题中的任何地方,特别是在标题中,细节和简洁是首选。希望这能有所帮助!我试图在JSONParser类中使用List而不是List,但由于UrlEncodedFormEntity类,它在httpPost.setEntity(新的UrlEncodedFormEntity(params))行中给出了错误;我不知道如何解决
public class UrlEncodedFormEntity extends org.apache.http.entity.StringEntity         
{
   public UrlEncodedFormEntity(java.util.List<? extends 
   org.apache.http.NameValuePair> parameters, java.lang.String encoding) 
   throws java.io.UnsupportedEncodingException { /* compiled code */ }

   public UrlEncodedFormEntity(java.util.List<? extends 
   org.apache.http.NameValuePair> parameters) throws 
   java.io.UnsupportedEncodingException { /* compiled code */ }
}