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


Java StringRequest.setRetryPolicy方法代码示例

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


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

示例1: check

import com.android.volley.toolbox.StringRequest; //导入方法依赖的package包/类
public void check(final Callback callback) {
    mCallback = callback;
    StringRequest request = new StringRequest(Request.Method.GET, UPDATE_URL, this, this);
    request.setRetryPolicy(new DefaultRetryPolicy(mTimeOut, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
    request.setTag("update-check");
    request.setShouldCache(false);
    mRequestQueue.add(request);
}
 
开发者ID:feifadaima,项目名称:https-github.com-hyb1996-NoRootScriptDroid,代码行数:9,代码来源:UpdateChecker.java

示例2: load

import com.android.volley.toolbox.StringRequest; //导入方法依赖的package包/类
public void load(String url, final OnStringListener listener) {
    StringRequest request = new StringRequest(url, new Response.Listener<String>() {
        @Override
        public void onResponse(String s) {
            listener.onSuccess(s);
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError volleyError) {
            listener.onError(volleyError);
        }
    });

    request.setRetryPolicy(new DefaultRetryPolicy(DefaultRetryPolicy.DEFAULT_TIMEOUT_MS,
            DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
            DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));

    VolleySingleton.getVolleySingleton(context).addToRequestQueue(request);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:StringModelImpl.java

示例3: execute

import com.android.volley.toolbox.StringRequest; //导入方法依赖的package包/类
public void execute() {
    final String url = URL + "/remind";
    StringRequest req = new StringRequest(Request.Method.POST, url, this, this) {
        @Override
        public HashMap<String, String> getHeaders() {
            return getDefaultHeaders();
        }

        @Override
        public byte[] getBody() throws AuthFailureError {
            Map<String, String> params = new HashMap<>();
            params.put("fromUsername", mUsername);
            params.put("toUsername", mToUsername);
            params.put("guid", mGuid);
            params.put("isRemindingRef", isRemindingRef ? "1" : "0");
            return new JSONObject(params).toString().getBytes();
        }
    };

    req.setRetryPolicy(new DefaultRetryPolicy(
            ASYNC_CONNECTION_NORMAL_TIMEOUT,
            DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
            0));
    VolleyRequestQueue.getInstance().addToRequestQueue(req);
}
 
开发者ID:Q115,项目名称:Goalie_Android,代码行数:26,代码来源:RESTRemind.java

示例4: execute

import com.android.volley.toolbox.StringRequest; //导入方法依赖的package包/类
public void execute() {
    String url;
    try {
        url = URL + "/getuserinfo?username=" + URLEncoder.encode(mUsername, "utf-8");
    } catch (UnsupportedEncodingException e) {
        url = URL + "/getuserinfo?username=" + mUsername;
    }

    StringRequest req = new StringRequest(Request.Method.GET, url, this, this) {
        @Override
        public HashMap<String, String> getHeaders() {
            return getDefaultHeaders();
        }
    };

    req.setRetryPolicy(new DefaultRetryPolicy(
            ASYNC_CONNECTION_NORMAL_TIMEOUT,
            DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
            0));
    VolleyRequestQueue.getInstance().addToRequestQueue(req);
}
 
开发者ID:Q115,项目名称:Goalie_Android,代码行数:22,代码来源:RESTGetUserInfo.java

示例5: execute

import com.android.volley.toolbox.StringRequest; //导入方法依赖的package包/类
public void execute() {
    final String url = URL + "/register";
    isRegistering = true;
    StringRequest req = new StringRequest(Request.Method.POST, url, this, this) {
        @Override
        public Map<String, String> getHeaders() {
            return getDefaultHeaders();
        }

        @Override
        public byte[] getBody() throws AuthFailureError {
            Map<String, String> params = new HashMap<>();
            params.put("username", mUsername);
            params.put("device", "android");
            params.put("pushID", mPushID);
            return new JSONObject(params).toString().getBytes();
        }
    };

    req.setRetryPolicy(new DefaultRetryPolicy(
            ASYNC_CONNECTION_EXTENDED_TIMEOUT,
            DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
            0));
    VolleyRequestQueue.getInstance().addToRequestQueue(req);
}
 
开发者ID:Q115,项目名称:Goalie_Android,代码行数:26,代码来源:RESTRegister.java

示例6: execute

import com.android.volley.toolbox.StringRequest; //导入方法依赖的package包/类
public void execute() {
    final String url = URL + "/updategoal";
    StringRequest req = new StringRequest(Request.Method.POST, url, this, this) {
        @Override
        public HashMap<String, String> getHeaders() {
            return getDefaultHeaders();
        }

        @Override
        public byte[] getBody() throws AuthFailureError {
            Map<String, String> params = new HashMap<>();
            params.put("username", mUsername);
            params.put("guid", mGuid);
            params.put("goalCompleteResult", String.valueOf(mGoalCompleteResult.ordinal()));
            return new JSONObject(params).toString().getBytes();
        }
    };

    req.setRetryPolicy(new DefaultRetryPolicy(
            ASYNC_CONNECTION_EXTENDED_TIMEOUT,
            DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
            0));
    VolleyRequestQueue.getInstance().addToRequestQueue(req);
}
 
开发者ID:Q115,项目名称:Goalie_Android,代码行数:25,代码来源:RESTUpdateGoal.java

示例7: execute

import com.android.volley.toolbox.StringRequest; //导入方法依赖的package包/类
public void execute() {
    final String url = URL + "/upvote";
    StringRequest req = new StringRequest(Request.Method.POST, url, this, this) {
        @Override
        public HashMap<String, String> getHeaders() {
            return getDefaultHeaders();
        }

        @Override
        public byte[] getBody() throws AuthFailureError {
            Map<String, String> params = new HashMap<>();
            params.put("username", mUsername);
            params.put("guid", mGuid);
            return new JSONObject(params).toString().getBytes();
        }
    };

    req.setRetryPolicy(new DefaultRetryPolicy(
            ASYNC_CONNECTION_NORMAL_TIMEOUT,
            DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
            0));
    VolleyRequestQueue.getInstance().addToRequestQueue(req);
}
 
开发者ID:Q115,项目名称:Goalie_Android,代码行数:24,代码来源:RESTUpvote.java

示例8: execute

import com.android.volley.toolbox.StringRequest; //导入方法依赖的package包/类
public void execute() {
    final String url = URL + "/sync";
    isSyncing = true;
    StringRequest req = new StringRequest(Request.Method.POST, url, this, this) {
        @Override
        public HashMap<String, String> getHeaders() {
            return getDefaultHeaders();
        }

        @Override
        public byte[] getBody() throws AuthFailureError {
            Map<String, String> params = new HashMap<>();
            params.put("username", mUsername);
            params.put("lastSyncedTime", String.valueOf(mLastSyncedTimeEpoch));
            return new JSONObject(params).toString().getBytes();
        }
    };

    req.setRetryPolicy(new DefaultRetryPolicy(
            ASYNC_CONNECTION_EXTENDED_TIMEOUT,
            DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
            0));
    VolleyRequestQueue.getInstance().addToRequestQueue(req);
}
 
开发者ID:Q115,项目名称:Goalie_Android,代码行数:25,代码来源:RESTSync.java

示例9: execute

import com.android.volley.toolbox.StringRequest; //导入方法依赖的package包/类
public void execute() {
    final String url = URL + "/updateuserinfo";
    StringRequest req = new StringRequest(Request.Method.POST, url, this, this) {
        @Override
        public HashMap<String, String> getHeaders() {
            return getDefaultHeaders();
        }

        @Override
        public byte[] getBody() throws AuthFailureError {
            Map<String, String> params = new HashMap<>();
            params.put("bio", mBio);
            params.put("username", mUsername);
            params.put("pushID", mPushID);
            return new JSONObject(params).toString().getBytes();
        }
    };

    req.setRetryPolicy(new DefaultRetryPolicy(
            ASYNC_CONNECTION_NORMAL_TIMEOUT,
            DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
            0));
    VolleyRequestQueue.getInstance().addToRequestQueue(req);
}
 
开发者ID:Q115,项目名称:Goalie_Android,代码行数:25,代码来源:RESTUpdateUserInfo.java

示例10: deleteRequest

import com.android.volley.toolbox.StringRequest; //导入方法依赖的package包/类
/**
 * DELETE string request.
 *
 * @param url      URL for post API request
 * @param listener Listener
 */
public static void deleteRequest(String url, final VolleyResponseListener listener) {
    StringRequest stringRequest = new StringRequest(Request.Method.DELETE, url, new Response.Listener<String>() {
        @Override
        public void onResponse(String s) {
            listener.onResponse(s);
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError volleyError) {
            if (volleyError != null) {
                listener.onError(volleyError);
            }
        }
    }) {
        @Override
        protected Response<String> parseNetworkResponse(NetworkResponse response) {
            listener.onNetworkResponse(response);
            return super.parseNetworkResponse(response);
        }

        @Override
        public Map<String, String> getHeaders() throws AuthFailureError {
            Map<String, String> params = new HashMap<String, String>();
            params.put("Accept", "application/json");
            params.put("Content-Type", "application/json; charset=UTF-8");
            params.put("Cache-Control", "no-cache");
            params.put("Authorization", "");
            return params;
        }

        @Override
        public Priority getPriority() {
            return Priority.IMMEDIATE;
        }
    };

    stringRequest.setRetryPolicy(new DefaultRetryPolicy(0, -1, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));

    VolleySingleton.getInstance().getRequestQueue().add(stringRequest);
}
 
开发者ID:rensamatar,项目名称:ez-volley,代码行数:47,代码来源:VolleyRequest.java

示例11: execute

import com.android.volley.toolbox.StringRequest; //导入方法依赖的package包/类
public void execute() {
    final String url = URL + "/newgoal";

    StringRequest req = new StringRequest(Request.Method.POST, url, this, this) {
        @Override
        public HashMap<String, String> getHeaders() {
            return getDefaultHeaders();
        }

        @Override
        public byte[] getBody() throws AuthFailureError {
            Map<String, String> params = new HashMap<>();
            params.put("username", mUsername);
            params.put("start", String.valueOf(mStart));
            params.put("end", String.valueOf(mEnd));
            params.put("wager", String.valueOf(mWager));
            params.put("encouragement", mEncouragement);
            params.put("referee", mReferee);
            params.put("title", mTitle);
            params.put("isGoalPublic", isGoalPublic ? "1" : "0");
            return new JSONObject(params).toString().getBytes();
        }
    };

    req.setRetryPolicy(new DefaultRetryPolicy(
            ASYNC_CONNECTION_EXTENDED_TIMEOUT,
            DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
            0));
    VolleyRequestQueue.getInstance().addToRequestQueue(req);
}
 
开发者ID:Q115,项目名称:Goalie_Android,代码行数:31,代码来源:RESTNewGoal.java

示例12: putStringRequest

import com.android.volley.toolbox.StringRequest; //导入方法依赖的package包/类
/**
 * PUT string request
 *
 * @param url      URL for post API request
 * @param listener Listener
 */
public static void putStringRequest(String url, final VolleyResponseListener listener) {
    StringRequest stringRequest = new StringRequest(Request.Method.PUT, url, new Response.Listener<String>() {
        @Override
        public void onResponse(String s) {
            listener.onResponse(s);
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError volleyError) {
            if (volleyError != null) {
                listener.onError(volleyError);
            }
        }
    }) {
        @Override
        protected Response<String> parseNetworkResponse(NetworkResponse response) {
            listener.onNetworkResponse(response);
            return super.parseNetworkResponse(response);
        }

        @Override
        public Map<String, String> getHeaders() throws AuthFailureError {
            Map<String, String> params = new HashMap<String, String>();
            params.put("Accept", "application/json");
            params.put("Content-Type", "application/json; charset=UTF-8");
            params.put("Cache-Control", "no-cache");
            params.put("Authorization", "");
            return params;
        }

        @Override
        public Priority getPriority() {
            return Priority.IMMEDIATE;
        }
    };

    stringRequest.setRetryPolicy(new DefaultRetryPolicy(0, -1, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));

    VolleySingleton.getInstance().getRequestQueue().add(stringRequest);
}
 
开发者ID:rensamatar,项目名称:ez-volley,代码行数:47,代码来源:VolleyRequest.java

示例13: logoutUser

import com.android.volley.toolbox.StringRequest; //导入方法依赖的package包/类
private void logoutUser() {

        // {host}/sessions
        String logoutUrl = QuireAPI.BASE_URL + QuireAPI.SESSIONS_ENDPOINT;

        final StringRequest stringRequest = new StringRequest(Request.Method.DELETE,
                logoutUrl, new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {

                LoginManager.getInstance().logOut();
                session.setLogin(false);

                startActivity(new Intent(mContext, WelcomeActivity.class));
                overridePendingTransition(R.anim.left_out, R.anim.right_in);
                finish();

            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                Toasty.error(mContext, "Error: " + error.toString(), Toast.LENGTH_SHORT).show();
            }
        }) {

            @Override
            public Map<String, String> getHeaders() throws AuthFailureError {

                HashMap<String, String> headers = new HashMap<>();
                headers.put("Authorization", Quire.access_token);

                return headers;

            }
        };

        stringRequest.setRetryPolicy(new DefaultRetryPolicy(
                0,
                DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
                DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));

        RequestQueue queue = Volley.newRequestQueue(mContext);
        queue.add(stringRequest);
    }
 
开发者ID:narenkukreja,项目名称:quire,代码行数:45,代码来源:NearbyProductsActivity.java

示例14: initiateResetPasswordProcess

import com.android.volley.toolbox.StringRequest; //导入方法依赖的package包/类
private void initiateResetPasswordProcess(final String email) {

        StringRequest strReq = new StringRequest(Request.Method.POST,
                                                 AppConfig.URL_FORGOTPASSREQUEST, new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {
                try {
                    response = response.replaceAll("NULL", "");
                    response = response.trim();
                    JSONObject json = new JSONObject(response);
                    System.out.println(response);
                    String result = json.getString("result");
                    Snackbar.make(findViewById(R.id.base), json.getString("message"), Snackbar.LENGTH_LONG).show();
                    if (result.equals(ViMarket.SUCCESS)) {
                        Snackbar.make(findViewById(R.id.base), json.getString("message"), Snackbar.LENGTH_LONG).show();
                        et_email.setVisibility(View.GONE);
                        layoutemail.setVisibility(View.GONE);
                        cancel.setVisibility(View.GONE);
                        forgot.setVisibility(View.GONE);
                        forgottext.setVisibility(View.GONE);
                        linear.setVisibility(View.VISIBLE);
                        verifytext.setText(getResources().getText(R.string.verifytextforgot) + "" + email);

                    }
                    else {

                        Snackbar.make(findViewById(R.id.base), json.getString("message"), Snackbar.LENGTH_LONG).show();

                    }
                    progress.setVisibility(View.INVISIBLE);
                } catch (JSONException e) {
                    e.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("phone", email + "");
                return params;
            }
        };
        strReq.setTag(this.getClass().getName());
        RetryPolicy mRetryPolicy = new DefaultRetryPolicy(
                0,
                DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
                DefaultRetryPolicy.DEFAULT_BACKOFF_MULT);
        strReq.setRetryPolicy(mRetryPolicy);
        VolleySingleton.getInstance(this).requestQueue.add(strReq);
    }
 
开发者ID:sega4revenge,项目名称:Sega,代码行数:59,代码来源:ForgotActivity.java

示例15: execute

import com.android.volley.toolbox.StringRequest; //导入方法依赖的package包/类
public void execute() {

        final String url = URL + "/uploadphoto";
        StringRequest req = new StringRequest(Request.Method.POST, url, this, this) {
            @Override
            public HashMap<String, String> getHeaders() {
                HashMap<String, String> headers = getDefaultHeaders();
                headers.put("Content-Type", "multipart/form-data;boundary=" + mBoundary);
                return headers;
            }

            @Override
            public byte[] getBody() {
                ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
                try {
                    String imageDispositionString = String.format("Content-Disposition: form-data; " +
                            "name=\"%s\"; filename=\"%s.png\"\r\n", mUsername, mUsername);
                    byte[] imageDisposition = getBytesFromString(imageDispositionString);
                    byte[] imageBoundary = getBytesFromString("\r\n" + "--" + mBoundary + "\r\n");
                    byte[] imageType = getBytesFromString("Content-Type: application/octet-stream\r\n\r\n");
                    byte[] image = getBytesFromBitmap(mProfileImage);

                    byteArrayOutputStream.write(imageBoundary);
                    byteArrayOutputStream.write(imageDisposition);
                    byteArrayOutputStream.write(imageType);
                    byteArrayOutputStream.write(image);
                    byteArrayOutputStream.write(imageBoundary);
                } catch (Exception e) {
                    Diagnostic.logError(Diagnostic.DiagnosticFlag.Other, "Failed to send body of photo");
                }

                return byteArrayOutputStream.toByteArray();
            }
        };

        req.setRetryPolicy(new DefaultRetryPolicy(
                Constants.ASYNC_CONNECTION_EXTENDED_TIMEOUT,
                DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
                0));
        VolleyRequestQueue.getInstance().addToRequestQueue(req);
    }
 
开发者ID:Q115,项目名称:Goalie_Android,代码行数:42,代码来源:RESTUploadPhoto.java


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