当前位置: 首页>>代码示例>>Java>>正文


Java Response.ErrorListener方法代码示例

本文整理汇总了Java中com.android.volley.Response.ErrorListener方法的典型用法代码示例。如果您正苦于以下问题:Java Response.ErrorListener方法的具体用法?Java Response.ErrorListener怎么用?Java Response.ErrorListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.android.volley.Response的用法示例。


在下文中一共展示了Response.ErrorListener方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: requestVolleyDeskList

import com.android.volley.Response; //导入方法依赖的package包/类
public void requestVolleyDeskList(final DeskList deskList){

        final JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(requestMethod, url, null, new Response.Listener<JSONObject>() {
            @Override
            public void onResponse(JSONObject response) {
                deskList.getDesk(response);
            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                Toast.makeText(context, String.valueOf(error), Toast.LENGTH_SHORT).show();
            }
        });

            requestQueue.add(jsonObjectRequest);

    }
 
开发者ID:yusufcakal,项目名称:RestaurantApp,代码行数:18,代码来源:Request.java

示例2: volleyGetJsonObjectRequest

import com.android.volley.Response; //导入方法依赖的package包/类
private String volleyGetJsonObjectRequest() {
    JsonObjectRequest request = new JsonObjectRequest(Request.Method.GET, Constant.JUHE_URL_GET, null, // 用post方式时,需更改为带请求参数的Object
            new Response.Listener<JSONObject>() {
                @Override
                public void onResponse(JSONObject response) {
                    Toast.makeText(MainActivity.this, response.toString(), Toast.LENGTH_SHORT).show();
                }
    },
            new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    Toast.makeText(MainActivity.this, error.toString(), Toast.LENGTH_SHORT).show();
                }
        });
    request.setTag(JSON_OBJECT_GET_TAG);
    MyApplication.getHttpQueues().add(request);
    return request.getTag().toString();
}
 
开发者ID:InnoFang,项目名称:Android-Code-Demos,代码行数:19,代码来源:MainActivity.java

示例3: ConfigurationRequest

import com.android.volley.Response; //导入方法依赖的package包/类
ConfigurationRequest(@Nullable String urlPrefix, String subscriptionKey, ConfigurationParam param,
    @Nullable Response.Listener<ConfigurationResult> listener,
    @Nullable Response.ErrorListener errorListener) {
  super(listener, errorListener);
  setMethod(Method.GET);
  setHeader("Ocp-Apim-Subscription-Key", subscriptionKey);
  String prefix = urlPrefix != null ? urlPrefix : DEFAULT_URL_PREFIX;
  Uri uri = Uri.parse(prefix);
  uri = uri.buildUpon()
      .appendPath("platform").appendPath(param.platform)
      .appendPath("app").appendPath(param.appId)
      .appendPath("version").appendPath(param.appVersion)
      .appendPath("") // for trailing slash
      .build();
  setUrl(uri.toString());

  setQueryParam("sdk", param.sdkVersion);
  setQueryParam("country", param.countryCode);
}
 
开发者ID:rakutentech,项目名称:android-perftracking,代码行数:20,代码来源:ConfigurationRequest.java

示例4: fileListRequest

import com.android.volley.Response; //导入方法依赖的package包/类
/**
 * 用户请求文件列表的网络通信
 */
public void fileListRequest(){
    String userId = sharedPreferences.getString("email","");
    String token  = sharedPreferences.getString("token","");
    RequestQueue requestQueue = MyApplication.getRequestQueue();
    JSONObject jsonObject = new JSONObject();
    try {
        jsonObject.put("userId",userId);
        jsonObject.put("token",token);
        Log.d("fileListRequest_JsonObj",jsonObject.toString());


    }catch (JSONException e){
        e.printStackTrace();
    }

    JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, url_filelistrequest, jsonObject, new Response.Listener<JSONObject>() {
        @Override
        public void onResponse(JSONObject response) {

            getListReceive getListReceive = new getListReceive();
            getListReceive.setStatus(response.optString("status"));
            getListReceive.setErrMsg(response.optString("errMsg"));
            getListReceive.setJsonObject(response.optJSONObject("jsonStrArray"));
            Log.d("getFileList_Response",response.toString());

            judge_fileListRequest(getListReceive.getStatus(),getListReceive.getErrMsg(),getListReceive.getJsonObject());

        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            Log.e("fileListRequest_Error",error.toString(),error);
        }
    });
    requestQueue.add(jsonObjectRequest);
}
 
开发者ID:Axe-Ishmael,项目名称:Blockly,代码行数:40,代码来源:LuaActivity.java

示例5: EaseBaseRequest

import com.android.volley.Response; //导入方法依赖的package包/类
public EaseBaseRequest(TypeToken<EaseResponse<T>> token, int method, String url, RequestHeaders headers, RequestBody bodyParams, Response.Listener<EaseResponse<T>> responseListener, Response.ErrorListener errorListener) {
    super(method, url, errorListener);
    mResponseListener = responseListener;
    mHeaders = headers;
    mTypeToken = token;
    mBodyParams = bodyParams;
}
 
开发者ID:allaudin,项目名称:ease-volley-wrapper,代码行数:8,代码来源:EaseBaseRequest.java

示例6: resetPassword

import com.android.volley.Response; //导入方法依赖的package包/类
/**
 * 用于修改密码的网络请求
 */
public void resetPassword(){
    final RequestQueue requestQueue =MyApplication.getRequestQueue();
    JSONObject jsonObject = new JSONObject();
    try {
        jsonObject.put("userPassword",password1);
        jsonObject.put("verifyCode",code);
        jsonObject.put("userId",email);
    }catch (JSONException e){
        e.printStackTrace();
    }
    Log.d("resetPassword_JsonObj",jsonObject.toString());

    JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, url_resetPassword, jsonObject, new Response.Listener<JSONObject>() {
        @Override
        public void onResponse(JSONObject response) {

            resetPasswordReceive resetPasswordReceive = new resetPasswordReceive();
            resetPasswordReceive.setStatus(response.optString("status"));
            resetPasswordReceive.setErrMsg(response.optString("errMsg"));
            resetPasswordReceive.setRemainNum(response.optString("remainNum"));
            Log.d("resetPassword_Response",resetPasswordReceive.getStatus()+"  "+resetPasswordReceive.getErrMsg()+" "+resetPasswordReceive.getRemainNum());

            judge_resetPassword(resetPasswordReceive.getStatus(),resetPasswordReceive.getErrMsg(),resetPasswordReceive.getRemainNum());

        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            Log.e("resetPassword_Error",error.toString(),error);
        }
    });

    requestQueue.add(jsonObjectRequest);
}
 
开发者ID:Axe-Ishmael,项目名称:Blockly,代码行数:38,代码来源:ForgetPasswordActivity.java

示例7: userLogin

import com.android.volley.Response; //导入方法依赖的package包/类
/**
     *用于登录操作的网络通讯
     */
    public void userLogin(){
        RequestQueue requestQueue = MyApplication.getRequestQueue();
        JSONObject jsonObject = new JSONObject();
//        String email ,password;
        try {
            jsonObject.put("userId",email);
            jsonObject.put("userPassword",password);
        }catch (JSONException e){
            e.printStackTrace();
        }
        Log.d("userLogin",jsonObject.toString());

        JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, url_login, jsonObject, new Response.Listener<JSONObject>() {
            @Override
            public void onResponse(JSONObject response) {

                userLoginRegisterReceive userLoginReceive = new userLoginRegisterReceive();
                userLoginReceive.setStatus(response.optString("status"));
                userLoginReceive.setErrMsg(response.optString("eerMsg"));
                userLoginReceive.setToken(response.optString("token"));
                userLoginReceive.setJsonObject(response.optJSONObject("jsonStr"));
                Log.d("userLogin_response",userLoginReceive.getStatus()+" "+"errMsg:"+userLoginReceive.getErrMsg()+" "+userLoginReceive.getToken());

                judge_userLogin(userLoginReceive.getStatus(),userLoginReceive.getErrMsg(),userLoginReceive.getToken(),userLoginReceive.getJsonObject());
            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                Log.e("userLogin",error.toString(),error);
            }
        });

        requestQueue.add(jsonObjectRequest);

    }
 
开发者ID:Axe-Ishmael,项目名称:Blockly,代码行数:39,代码来源:LoginActivity.java

示例8: PostRequest

import com.android.volley.Response; //导入方法依赖的package包/类
public PostRequest(String url, Map<String, String> apiHeaders, String contentType, HttpEntity entity, Response.Listener<String> listener, Response.ErrorListener errorListener) {
  super(Method.POST, url, errorListener);
  mListener = listener;
  this.entity = entity;
  this.contentType = contentType;
  this.apiHeaders = apiHeaders;
}
 
开发者ID:wondenge,项目名称:payments-Android-SDK,代码行数:8,代码来源:PostRequest.java

示例9: UpdateUser

import com.android.volley.Response; //导入方法依赖的package包/类
protected void UpdateUser()
{
    StringRequest stringGetRequest = new StringRequest(Request.Method.POST, "https://greatnorthcap.000webhostapp.com/PHP/updateuser.php",
            new Response.Listener<String>(){
                @Override
                public void onResponse(String response)
                {
                    Toast.makeText(SearchedAccountProfileActivity.this, response, Toast.LENGTH_SHORT).show();
                }

            }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error)
        {
            Toast.makeText(SearchedAccountProfileActivity.this,error.toString(),Toast.LENGTH_SHORT).show();

        }
    }){            @Override
    protected Map<String, String> getParams() throws AuthFailureError {
        Map<String, String> params = new HashMap<>();
        params.put(UserPref.getKeyUserId(), ID);
        params.put("BorrowerType", BorrowerType);
        params.put("LenderType", LenderType);
        return params;
    }}
            ;
    requestQueue = Volley.newRequestQueue(this);
    requestQueue.add(stringGetRequest);
}
 
开发者ID:zhirunn,项目名称:CompassDemo,代码行数:30,代码来源:SearchedAccountProfileActivity.java

示例10: registerUser

import com.android.volley.Response; //导入方法依赖的package包/类
public void registerUser(final User user, final String deviceToken, final VolleyCallback
        callback) {

    Log.d(TAG, "registerUser: " + user);
    Log.d(TAG, "registerUser: " + deviceToken);
    StringRequest stringRequest = new StringRequest(Request.Method.POST, TTLEndpoints
            .URL_USER_REGISTER,
            new Response.Listener<String>() {
                @Override
                public void onResponse(String response) {
                    callback.onSuccess(response);
                }
            },
            new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    callback.onError(error.toString());
                }
            }) {
        @Override
        protected Map<String, String> getParams() throws AuthFailureError {
            Map<String, String> param = new HashMap<>();
            param.put(NetworkKeys.KEY_USERNAME, user.getUsername());
            param.put(NetworkKeys.KEY_EMAIL, user.getEmail());
            param.put(NetworkKeys.KEY_PASSWORD, user.getPassword());
            param.put(NetworkKeys.KEY_DEVICE_TOKEN, deviceToken);
            return param;
        }
    };
    AppController.getInstance().addToRequestQueue(stringRequest, TAG);
}
 
开发者ID:adityakamble49,项目名称:gofun-app,代码行数:32,代码来源:TTLNetwork.java

示例11: GsonRequest

import com.android.volley.Response; //导入方法依赖的package包/类
/**
 * Make a GET request and return a parsed object from JSON.
 *
 * @param url     URL of the request to make
 * @param clazz   Relevant class object, for Gson's reflection
 * @param headers Map of request headers
 */
public GsonRequest(String url, Class<T> clazz, Map<String, String> headers,
                   Response.Listener<T> listener, Response.ErrorListener errorListener) {
    super(Method.GET, url, errorListener);
    this.clazz = clazz;
    this.headers = headers;
    this.listener = listener;
}
 
开发者ID:googlecodelabs,项目名称:android-network-security-config,代码行数:15,代码来源:GsonRequest.java

示例12: unLiked

import com.android.volley.Response; //导入方法依赖的package包/类
@Override
public void unLiked(LikeButton likeButton) {
    requestQueue = Volley.newRequestQueue(getContext());
    //
    StringRequest request = new StringRequest(Request.Method.POST, AppConfig.URL_FAVORITE, new Response.Listener<String>() {
        @Override
        public void onResponse(String response) {
            //                        Toast.makeText(getContext(),response.toString(), Toast.LENGTH_SHORT).show();
            System.out.println(response);
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            Toast.makeText(getContext(), "Error", Toast.LENGTH_LONG).show();
        }
    }) {
        @Override
        protected Map<String, String> getParams() throws AuthFailureError {
            Map<String, String> param = new HashMap<>();
            param.put("userrated", String.valueOf(session.getLoginId()));
            param.put("userrating", String.valueOf(seller.userid));
            return param;

        }

    };

    requestQueue.add(request);
}
 
开发者ID:sega4revenge,项目名称:Sega,代码行数:30,代码来源:ProfileDetailFragment.java

示例13: details

import com.android.volley.Response; //导入方法依赖的package包/类
public static void details(String bookId, final ModelListener<List<BookInventory>> listener) {
    JsonObjectRequest r = new JsonObjectRequest(Request.Method.GET, baseURL + "/details?book_id=" + bookId, null, new Response.Listener<JSONObject>() {
        @Override
        public void onResponse(JSONObject response) {
            // Parse response here
            List<BookInventory> result = new ArrayList<>();
            try {
                JSONArray bookInventories = response.getJSONObject("result").getJSONArray("inventory");
                for (int i = 0; i < bookInventories.length(); i++) {
                    JSONObject jsonDetails = bookInventories.getJSONObject(i);
                    BookInventory bookInventory = new BookInventory();

                    if (jsonDetails.has("location") && !jsonDetails.isNull("location"))
                        bookInventory.location = jsonDetails.getString("location");

                    if (jsonDetails.has("login_number") && !jsonDetails.isNull("login_number"))
                        bookInventory.login_number = jsonDetails.getString("login_number");

                    if (jsonDetails.has("year") && !jsonDetails.isNull("year"))
                        bookInventory.year = jsonDetails.getString("year");

                    if (jsonDetails.has("acquisition_number") && !jsonDetails.isNull("acquisition_number"))
                        bookInventory.acquisition_number = jsonDetails.getString("acquisition_number");

                    if (jsonDetails.has("type") && !jsonDetails.isNull("type"))
                        bookInventory.type = jsonDetails.getString("type");

                    if (jsonDetails.has("inventory") && !jsonDetails.isNull("inventory"))
                        bookInventory.inventory = jsonDetails.getString("inventory");

                    if (jsonDetails.has("availability") && !jsonDetails.isNull("availability"))
                        bookInventory.availability = jsonDetails.getString("availability");

                    result.add(bookInventory);
                }
                listener.onData(result, "OK");
            } catch (JSONException e) {
                listener.onData(null, "解析数据失败");
            }
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            listener.onData(null, "连接学校服务器超时");
        }
    });
    SAGlobal.sharedRequestQueue.add(r);
}
 
开发者ID:njitdev,项目名称:sa-android,代码行数:49,代码来源:LibraryModels.java

示例14: deleteLocation

import com.android.volley.Response; //导入方法依赖的package包/类
/**
 * Metodo cancellazione parcheggio sulla piattaforma
 * @param id Id del parcheggio
 * @param apiCallback callback
 */
void deleteLocation(String id, @NonNull final APICallback apiCallback) {
    if(id != null && !id.isEmpty())
    {
        if(HelperRete.isNetworkAvailable(getApplicationContext())) {
            JsonObjectRequest volleyRequest = new JsonObjectRequest(Request.Method.DELETE, BASE_URL + id, null, new Response.Listener<JSONObject>() {
                @Override
                public void onResponse(JSONObject response) {
                    try {
                        String status = response.getString("status");
                        if (status.equals("Success"))
                            apiCallback.onResult(false, response);
                        else
                            apiCallback.onResult(true, response);
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                }
            }, new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    NetworkResponse networkResponse = error.networkResponse;
                    if (networkResponse != null && (networkResponse.statusCode == 401 || networkResponse.statusCode == 403)) {
                        // HTTP Status Code: 401 Unauthorized, 403 Forbidden
                        System.out.println("aaaaa");
                        apiCallback.onAuthError();
                    }
                }
            }){
                @Override
                public Map<String, String> getHeaders() throws AuthFailureError {
                    Map<String, String> map = new HashMap<>();
                    map.put("Accept", "application/json");
                    map.put("Authorization", SharedPrefsHelper.getInstance().getApiKey(getApplicationContext()));
                    return map;
                }
            };

            RequestQueue requestQueue = Volley.newRequestQueue(getApplicationContext());
            requestQueue.add(volleyRequest);
        }
    }
}
 
开发者ID:IelloDevTeam,项目名称:IelloAndroidAdminApp,代码行数:48,代码来源:APIHandler.java

示例15: downloadRate

import com.android.volley.Response; //导入方法依赖的package包/类
private void downloadRate() {
    StringRequest strReq = new StringRequest(Request.Method.POST,
                                             AppConfig.URL_RATEDETAILPROFILE, new Response.Listener<String>() {
        @Override
        public void onResponse(String response) {
            try {

                JSONObject jObj = new JSONObject(response);
                JSONArray feedArray = jObj.getJSONArray("rate");
                ratee = new Rate();
                for (int i = 0; i < feedArray.length(); i++) {
                    final JSONObject feedObj = (JSONObject) feedArray.get(i);
                    //add product to list product

                    switch (feedObj.getInt("point")) {
                        case 1:
                            ratee.onestar = Integer.parseInt(feedObj.getString("count"));

                            break;
                        case 2:
                            ratee.twostar = Integer.parseInt(feedObj.getString("count"));

                            break;
                        case 3:
                            ratee.threestar = Integer.parseInt(feedObj.getString("count"));

                            break;
                        case 4:
                            ratee.fourstar = Integer.parseInt(feedObj.getString("count"));

                            break;
                        case 5:
                            ratee.fivestar = Integer.parseInt(feedObj.getString("count"));

                            break;
                    }

                }
                Log.e("favorites", response);
                rate1 = jObj.getString("rate1");
                point1 = jObj.getString("count");
                countfavorites = jObj.getString("countfavorites");
                Log.e("RATEOK", "rate: " + rate1 + " " + "point: " + point1);
                onDownloadRateSuccessful();
                onDownloadSuccessful();
            } catch (Exception ex) {
                // JSON parsing error
                ex.printStackTrace();
            }
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            error.printStackTrace();
        }
    }) {
        @Override
        protected Map<String, String> getParams() {
            // Posting parameters to login url
            Map<String, String> params = new HashMap<>();
            params.put("userid", sellerid + "");
            return params;
        }
    };
    strReq.setTag(this.getClass().getName());
    VolleySingleton.getInstance(getActivity()).requestQueue.add(strReq);
}
 
开发者ID:sega4revenge,项目名称:Sega,代码行数:68,代码来源:ProfileDetailFragment.java


注:本文中的com.android.volley.Response.ErrorListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。