Android Studio-不建议使用NameValuePair和HttpParams [英] Android Studio - NameValuePair and HttpParams is deprecated
本文介绍了Android Studio-不建议使用NameValuePair和HttpParams的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是Android开发的新手,并且遇到了一些过时的问题.在Android Studio中,这表明不建议使用 NameValuePair
和 HttpParams
.
I am new to Android development and I am have some deprecated issues. In Android Studio, it is stating that the NameValuePair
and HttpParams
is deprecated.
ArrayList<NameValuePair> dataToSend = new ArrayList<>();
dataToSend.add(new BasicNameValuePair("fname", user.fname));
dataToSend.add(new BasicNameValuePair("lname", user.lname));
dataToSend.add(new BasicNameValuePair("email", user.email));
dataToSend.add(new BasicNameValuePair("password", user.password));
HttpParams httpRequestParams = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(httpRequestParams, CONNECTION_TIMEOUT);
HttpConnectionParams.setSoTimeout(httpRequestParams, CONNECTION_TIMEOUT);
HttpClient client = new DefaultHttpClient(httpRequestParams);
HttpPost post = new HttpPost(SERVER_ADDRESS + "register");
在寻找答案时,我被发送使用 openconnection()
,但是我看不到它如何适用于上面的代码.
When searching for answers, I am getting sent to use openconnection()
, but I don't see how that applies to code above.
推荐答案
您尝试使用ContentValues吗?
Did you try to use ContentValues ?
从这段代码中,我不确定它是否对您有帮助.
From this snippet of code I am not sure if it would help you.
ContentValues values=new ContentValues();
values.put("fname",user.fname);
values.put("lname", user.lname);
values.put("email",user.email);
values.put("password",user.password);
这篇关于Android Studio-不建议使用NameValuePair和HttpParams的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文