简体   繁体   English

从在线数据库获取数据

[英]Getting data from Online Db

protected Void doInBackground(Void... params) {
    ArrayList<NameValuePair> dataToSend = new ArrayList<>();
    dataToSend.add(new BasicNameValuePair("Name", user.name));
    return null;
}

my activity was unable to import NameValuePair data model thats why i was getting this issue, i think i have not imported the proper library for this function.我的活动无法导入 NameValuePair 数据模型,这就是我遇到此问题的原因,我想我没有为此功能导入正确的库。

The IDE can't find a class with name "NameValuePair". IDE 找不到名称为“NameValuePair”的类。

It seems that there is an Interface org.apache.http.NameValuePair which is deprecated for API levels 22 and higher.似乎有一个接口 org.apache.http.NameValuePair对于 API 级别 22 及更高版本已弃用。

So, as suggested in the Preview (Behavior Changes) for Android M you should work with 'HttpURLConnection' or因此,正如Android M预览(行为更改)中所建议的,您应该使用“HttpURLConnection”或

declare the following compile-time dependency in your build.gradle file:在 build.gradle 文件中声明以下编译时依赖项:

android {
useLibrary 'org.apache.http.legacy'
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM