我需要使用不同的参数,响应和带有齐射的参数发出两个请求。以下是我的代码
private void LoadFirst() {
pDialog = new ProgressDialog(getActivity());
// Showing progress dialog before making http request
pDialog.setMessage("Loading...");
pDialog.show();
final StringRequest userReq = new StringRequest(Method.POST,
AppConfig.URL_REGISTER, jsonSubjectListener, errorSubjectListener) {
@Override
protected Map<String, String> getParams() {
// Posting params to register url
Map<String, String> params = new HashMap<String, String>();
params.put("tag", "retrieveFirst");
return params;
}
};
AppController.getInstance().addToRequestQueue(userReq);
}
}
private void LoadSecond(final String user_type) {
// Session manager
session = new SessionManager(getActivity().getApplicationContext());
// initialising progress dialog
pDialog = new ProgressDialog(getActivity());
// Showing progress dialog before making http request
pDialog.setMessage("Loading...");
pDialog.show();
StringRequest userReq = new StringRequest(Method.POST,
AppConfig.URL_REGISTER, jsonListener, errorListener) {
@Override
protected Map<String, String> getParams() {
// Posting params to register url
Map<String, String> params = new HashMap<String, String>();
params.put("tag", "retrieveSecond");
params.put("user_type", user_type);
return params;
}
};
AppController.getInstance().addToRequestQueue(userReq);
}
然后我在片段的onActivityCreated下调用了这两个函数。但它无限期地继续加载。我在RequestFuture上阅读了一些内容但我无法看到它如何帮助我使用两个不同的参数,errorListeners和ResponseListeners。感谢