I have url that has a json Array which contains a large amount of data. I call the url with volly jsonArrayRequest like this
我有一个包含大量数据的json数组的url。我像这样用volly jsonArrayRequest调用url
public void makeJsonArrayReq(){
showProgressDialog();
JsonArrayRequest req = new JsonArrayRequest(Const.URL_IPD_ADMITED,
new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
Log.d("response ================", response.toString());
textView.setText(response.toString());
hideProgressDialog();
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
VolleyLog.d("Error", "Error: " + error.getMessage());
textView.setText("Error Occurs ");
hideProgressDialog();
}
});
AppController.getInstance().addToRequestQueue(req, "array");
}
}
My devise shows progressDialog for some time after that time it hang out the app then after a few minute it shows the response in the texview but it very lengthy process and it same when internet connection off and extract from volley cache. How can I handle the URL in my apps?
我的设计显示progressDialog一段时间后,它挂出了应用程序,然后几分钟后它显示texview中的响应,但它非常冗长的过程,当互联网连接关闭和从凌空缓存中提取时相同。如何处理我的应用中的网址?
1 个解决方案
#1
0
You need to change your api a bit to support pagination. There are several pagination techniques available, you have to choose one that suites your case.
你需要改变你的api以支持分页。有几种可用的分页技术,您必须选择一种适合您的情况。
In Android
you can save the last fetched pageNumber
(if that is what your API returns as page identifier) and your api should accept this variable in request (mostly through query params)
在Android中,您可以保存上次获取的pageNumber(如果这是您的API返回的页面标识符),并且您的api应该在请求中接受此变量(主要通过查询参数)
http://43.255.22.123:3000/android/mis/get/ipdAdmitPatMd?pageId=1
And in the next request it should update the pageId to 2.
在下一个请求中,它应该将pageId更新为2。
Since the question is too broad hence providing exact code solution is not possible therefore I have explained the concept.
由于问题太宽泛,因此无法提供精确的代码解决方案,因此我已经解释了这个概念。
#1
0
You need to change your api a bit to support pagination. There are several pagination techniques available, you have to choose one that suites your case.
你需要改变你的api以支持分页。有几种可用的分页技术,您必须选择一种适合您的情况。
In Android
you can save the last fetched pageNumber
(if that is what your API returns as page identifier) and your api should accept this variable in request (mostly through query params)
在Android中,您可以保存上次获取的pageNumber(如果这是您的API返回的页面标识符),并且您的api应该在请求中接受此变量(主要通过查询参数)
http://43.255.22.123:3000/android/mis/get/ipdAdmitPatMd?pageId=1
And in the next request it should update the pageId to 2.
在下一个请求中,它应该将pageId更新为2。
Since the question is too broad hence providing exact code solution is not possible therefore I have explained the concept.
由于问题太宽泛,因此无法提供精确的代码解决方案,因此我已经解释了这个概念。