當前位置: 首頁>>代碼示例>>Java>>正文


Java JsonArrayRequest類代碼示例

本文整理匯總了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);
}
 
開發者ID:ferozbaig96,項目名稱:VolleySimple,代碼行數:33,代碼來源:VolleySimple.java

示例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);
    }
 
開發者ID:brunomassa,項目名稱:LuxVilla,代碼行數:24,代碼來源:separadoraveiro.java

示例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);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:24,代碼來源:Fdv_JsonArrayRequest.java

示例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);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:25,代碼來源:Fdv_JsonArrayRequest.java

示例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);
}
 
開發者ID:chashmeetsingh,項目名稱:TrackIt-Android,代碼行數:39,代碼來源:SearchActivity.java

示例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);
    }
 
開發者ID:brunomassa,項目名稱:LuxVilla,代碼行數:23,代碼來源:separadorporto.java

示例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);
    }
 
開發者ID:brunomassa,項目名稱:LuxVilla,代碼行數:20,代碼來源:searchableactivity.java

示例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);
                    }
                }
        );
    }
 
開發者ID:BandUp,項目名稱:band-up-android,代碼行數:21,代碼來源:BandUpRepository.java

示例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);
}
 
開發者ID:PGMacDesign,項目名稱:PGMacTips,代碼行數:23,代碼來源:VolleyCalls.java

示例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);
}
 
開發者ID:afnecors,項目名稱:Mood-On-Map,代碼行數:25,代碼來源:MyMarker2.java

示例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);
}
 
開發者ID:afnecors,項目名稱:Mood-On-Map,代碼行數:23,代碼來源:NearMarkerActivity.java

示例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);
}
 
開發者ID:afnecors,項目名稱:Mood-On-Map,代碼行數:25,代碼來源:ShowInfoMarkerActivity.java

示例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);
}
 
開發者ID:afnecors,項目名稱:Mood-On-Map,代碼行數:23,代碼來源:ShowInfoMarkerActivity.java

示例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);
    }
 
開發者ID:Circle-Of-Music-Makers,項目名稱:com-android,代碼行數:25,代碼來源:PotmAdapter.java

示例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);
    }
 
開發者ID:Circle-Of-Music-Makers,項目名稱:com-android,代碼行數:26,代碼來源:ComTracksAdapter.java


注:本文中的com.android.volley.toolbox.JsonArrayRequest類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。