v23中弃用了来自API类别的数据请求

时间:2018-12-15 16:45:48

标签: json

我想将我的项目转移到新版本的SDK,但是我遇到了旧方法,即来自数据库的请求。帮助将旧方法转换为新方法。

public void parseJSONData(){:

clearData();

try {
    // request data from Category API
    HttpURLConnection client = new DefaultHttpClient();
    HttpConnectionParams.setConnectionTimeout(client.getParams(), 15000);
    HttpConnectionParams.setSoTimeout(client.getParams(), 15000);
    HttpUriRequest request = new HttpGet(CategoryAPI);
    HttpResponse response = client.execute(request);
    InputStream atomInputStream = response.getEntity().getContent();
    BufferedReader in = new BufferedReader(new InputStreamReader(atomInputStream));

    String line;
    String str = "";
    while ((line = in.readLine()) != null){
        str += line;
    }

0 个答案:

没有答案