本文整理匯總了Java中com.android.volley.toolbox.JsonArrayRequest類的典型用法代碼示例。如果您正苦於以下問題:Java JsonArrayRequest類的具體用法?Java JsonArrayRequest怎麽用?Java JsonArrayRequest使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
JsonArrayRequest類屬於com.android.volley.toolbox包,在下文中一共展示了JsonArrayRequest類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: placeJsonArrayRequest
import com.android.volley.toolbox.JsonArrayRequest; //導入依賴的package包/類
/**
* @param apiTag tag to uniquely distinguish Volley requests. Null is allowed
* @param url URL to fetch the string at
* @param httpMethod the request method to use (GET or POST)
* @param params A {@link JSONArray} to post with the request. Null is allowed and
* indicates no parameters will be posted along with request.
* @param headers optional Http headers
* @param serverCallback Listener to receive the String response
*/
public void placeJsonArrayRequest(@Nullable final String apiTag, String url, int httpMethod, @Nullable JSONArray params, final @Nullable HashMap<String, String> headers, final ServerCallback serverCallback) {
Request request = new JsonArrayRequest(httpMethod, url, params, new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
serverCallback.onAPIResponse(apiTag, response);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
serverCallback.onErrorResponse(apiTag, error);
}
}) {
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
return headers != null ? headers : super.getHeaders();
}
};
request.setRetryPolicy(retryPolicy);
addToRequestQueue(request);
}
示例2: sendjsonRequest
import com.android.volley.toolbox.JsonArrayRequest; //導入依賴的package包/類
private void sendjsonRequest(){
JsonArrayRequest jsonArrayRequest=new JsonArrayRequest(Request.Method.GET,"http://brunoferreira.esy.es/serverdata.php",null, new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
casas=parsejsonResponse(response);
adaptador.setCasas(casas);
progressBar.setVisibility(View.GONE);
swipeRefreshLayout.setVisibility(View.VISIBLE);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
progressBar.setVisibility(View.GONE);
swipeRefreshLayout.setVisibility(View.VISIBLE);
Snackbar.make(recyclerViewtodas,"Falha ao ligar ao servidor",Snackbar.LENGTH_LONG).show();
}
});
requestQueue.add(jsonArrayRequest);
}
示例3: get
import com.android.volley.toolbox.JsonArrayRequest; //導入依賴的package包/類
/**
* 請求返回JSONArray對象 Get請求 無參數,或者get請求的參數直接拚接在URL上麵
* @param url 請求地址
* @param listener 數據返回回調接口
*/
public void get(String url, final Fdv_CallBackListener<JSONArray> listener){
JsonArrayRequest jsonArrayRequest=new JsonArrayRequest(Request.Method.GET, url, null, new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
if(listener!=null){
listener.onSuccessResponse(response);
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
if(listener!=null){
listener.onErrorResponse(error);
}
}
});
addRequest(jsonArrayRequest);
}
示例4: post
import com.android.volley.toolbox.JsonArrayRequest; //導入依賴的package包/類
/**
* POST請求返回JSONArray對象
* @param url 請求地址
* @param listener 請求數據返回回調接口
* @param params POST請求參數
*/
public void post(String url, final Fdv_CallBackListener<JSONArray> listener,Map<String,String> params){
JsonArrayRequest jsonArrayRequest=new JsonArrayRequest(Request.Method.POST, url, null, new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
if(listener!=null){
listener.onSuccessResponse(response);
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
if(listener!=null){
listener.onErrorResponse(error);
}
}
});
addRequest(jsonArrayRequest,params);
}
示例5: loadSearchSuggestions
import com.android.volley.toolbox.JsonArrayRequest; //導入依賴的package包/類
private void loadSearchSuggestions(final String query) {
String showName = query.replaceAll("\\s", "+");
RequestQueue requestQueue = VolleySingleton.getInstance().getRequestQueue();
JsonArrayRequest req = new JsonArrayRequest(
API.TV_MAZE_SEARCH + showName,
new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
List<SearchSuggestions> searchSuggestions = new ArrayList<>();
JSONObject object;
try {
for (int j = 0; j < response.length() && searchSuggestions.size() < 5; j++) {
object = response.getJSONObject(j).getJSONObject("show");
SearchSuggestions suggestion = new SearchSuggestions(object.getString("name"));
if (!searchSuggestions.contains(suggestion)) {
searchSuggestions.add(suggestion);
}
}
} catch (JSONException e) {
//Log.e("JSON exception", e.getMessage());
}
if (searchView.isSearchBarFocused()) {
searchView.swapSuggestions(searchSuggestions);
}
searchView.hideProgress();
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
searchView.hideProgress();
}
});
req.setRetryPolicy(new DefaultRetryPolicy(
5000, DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
requestQueue.add(req);
}
示例6: sendjsonRequest
import com.android.volley.toolbox.JsonArrayRequest; //導入依賴的package包/類
private void sendjsonRequest(){
JsonArrayRequest jsonArrayRequest=new JsonArrayRequest(Request.Method.GET,"http://brunoferreira.esy.es/serverdata.php",null, new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
casas=parsejsonResponse(response);
adaptador.setCasas(casas);
progressBar.setVisibility(View.GONE);
swipeRefreshLayout.setVisibility(View.VISIBLE);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
progressBar.setVisibility(View.GONE);
swipeRefreshLayout.setVisibility(View.VISIBLE);
Snackbar.make(recyclerViewtodas,"Falha ao ligar ao servidor",Snackbar.LENGTH_LONG).show();
}
});
requestQueue.add(jsonArrayRequest);
}
示例7: sendjsonRequest
import com.android.volley.toolbox.JsonArrayRequest; //導入依賴的package包/類
private void sendjsonRequest(){
JsonArrayRequest jsonArrayRequest=new JsonArrayRequest(Request.Method.GET,"http://brunoferreira.esy.es/serverdata.php",null, new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
casas=parsejsonResponse(response);
adaptador.setCasas(casas);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Snackbar.make(rvc1,"Falha ao ligar ao servidor",Snackbar.LENGTH_LONG).show();
}
});
requestQueue.add(jsonArrayRequest);
}
示例8: createArrayRequest
import com.android.volley.toolbox.JsonArrayRequest; //導入依賴的package包/類
private JsonArrayRequest createArrayRequest(int httpMethod, String url, JSONArray data, final BandUpResponseListener responseListener, final BandUpErrorListener errorListener) {
return new JsonArrayRequest(
httpMethod,
url,
data,
new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
responseListener.onBandUpResponse(response);
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
errorListener.onBandUpErrorResponse(error);
}
}
);
}
示例9: startJsonArrayRequest
import com.android.volley.toolbox.JsonArrayRequest; //導入依賴的package包/類
public void startJsonArrayRequest(Context context){
String url = "http://my-json-feed";
JsonArrayRequest jsObjRequest = new JsonArrayRequest
(Request.Method.GET, url, null, new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
String str = response.toString();
//Do stuff with string here.
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
//Do stuff with response here
}
});
// Access the RequestQueue through your singleton class.
VolleySingleton.getInstance(context).addToRequestQueue(jsObjRequest);
}
示例10: getData
import com.android.volley.toolbox.JsonArrayRequest; //導入依賴的package包/類
protected void getData(final VolleyResponseListener listener){
Bundle extras = getIntent().getExtras();
String android_id = extras.getString("android_id");
String url = "http://afnecors.altervista.org/android2016/api.php/markers?id_device="+android_id;
JsonArrayRequest jsObjRequest = new JsonArrayRequest
(Request.Method.GET, url, null, new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
listener.onResponse(response);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
// TODO Auto-generated method stub
}
});
// Access the RequestQueue through your singleton class.
MySingleton.getInstance(this).addToRequestQueue(jsObjRequest);
}
示例11: getData
import com.android.volley.toolbox.JsonArrayRequest; //導入依賴的package包/類
protected void getData(final VolleyResponseListener listener){
String url = "http://afnecors.altervista.org/android2016/api.php/markers";
JsonArrayRequest jsObjRequest = new JsonArrayRequest
(Request.Method.GET, url, null, new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
listener.onResponse(response);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
// TODO Auto-generated method stub
}
});
// Access the RequestQueue through your singleton class.
MySingleton.getInstance(this).addToRequestQueue(jsObjRequest);
}
示例12: getData
import com.android.volley.toolbox.JsonArrayRequest; //導入依賴的package包/類
protected void getData(final VolleyResponseListener listener){
Bundle extras = getIntent().getExtras();
final int id_marker = extras.getInt("id_marker");
String url = "http://afnecors.altervista.org/android2016/api.php/markers/"+id_marker;
JsonArrayRequest jsObjRequest = new JsonArrayRequest
(Request.Method.GET, url, null, new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
listener.onResponse(response);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
// TODO Auto-generated method stub
}
});
// Access the RequestQueue through your singleton class.
MySingleton.getInstance(this).addToRequestQueue(jsObjRequest);
}
示例13: deleteData
import com.android.volley.toolbox.JsonArrayRequest; //導入依賴的package包/類
protected void deleteData(int id){
String url = "http://afnecors.altervista.org/android2016/api.php/markers/"+id;
JsonArrayRequest jsObjRequest = new JsonArrayRequest
(Request.Method.DELETE, url, null, new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
listener.onResponse(response);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
// TODO Auto-generated method stub
}
});
// Access the RequestQueue through your singleton class.
MySingleton.getInstance(this).addToRequestQueue(jsObjRequest);
}
示例14: PotmAdapter
import com.android.volley.toolbox.JsonArrayRequest; //導入依賴的package包/類
public PotmAdapter(Context mContext) {
super();
this.mContext = mContext;
RequestQueue requestQueue = Volley.newRequestQueue(mContext);
JsonArrayRequest trackRequest = new JsonArrayRequest(Request.Method.GET, com_url + "getPOTMs", null, new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
try {
for (int i = 0; i < response.length(); i++) {
potms.add(new Potm(response.getJSONObject(i)));
}
notifyDataSetChanged();
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
// Couldn't fetch data
}
});
requestQueue.add(trackRequest);
}
示例15: ComTracksAdapter
import com.android.volley.toolbox.JsonArrayRequest; //導入依賴的package包/類
public ComTracksAdapter(Context mContext) {
super();
this.mContext = mContext;
mTrackList = new ArrayList<>();
RequestQueue requestQueue = Volley.newRequestQueue(mContext);
JsonArrayRequest trackRequest = new JsonArrayRequest(Request.Method.GET, com_url + "getTracks", null, new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
try {
for (int i = 0; i < response.length(); i++) {
mTrackList.add(new ComTrack(response.getJSONObject(i)));
}
notifyDataSetChanged();
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
// Couldn't fetch data
}
});
requestQueue.add(trackRequest);
}