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


Java DefaultRetryPolicy.DEFAULT_MAX_RETRIES属性代码示例

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


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

示例1: setRequestTimeout

private void setRequestTimeout(int ms) {
    int timeout = (ms == 0) ? DefaultRetryPolicy.DEFAULT_TIMEOUT_MS : ms;

    mRetryPolicy = new DefaultRetryPolicy(timeout,
            DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
            DefaultRetryPolicy.DEFAULT_BACKOFF_MULT);
}
 
开发者ID:socoolby,项目名称:CoolClock,代码行数:7,代码来源:NetworkService.java

示例2: generateRetryPolicy

/**
 * Generate a default retry policy (30 seconds for the timeout, 1 retry maximum, 1 backoff multiplier)
 * @return a default retry policy, not null
 */
@NonNull
private static RetryPolicy generateRetryPolicy() {
    return new DefaultRetryPolicy(requestTimeout,
            DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
            DefaultRetryPolicy.DEFAULT_BACKOFF_MULT);
}
 
开发者ID:neopixl,项目名称:Spitfire,代码行数:10,代码来源:SpitfireManager.java

示例3: makeRequest

/**
 * 如果传入的tag有效,则可以通过该tag取消请求的发送
 *
 * @param request    req
 * @param requestTag tag
 */
private void makeRequest(VolleyRequest request, String requestTag) {
    if (!TextUtils.isEmpty(requestTag)) {
        request.setTag(requestTag);
    }
    // step4:放入请求队列
    RequestQueue requestQueue = VolleyManager.getInstance(mContext).getRequestQueue();
    int socketTimeout = 5000;//30 seconds - change to what you want
    RetryPolicy policy = new DefaultRetryPolicy(socketTimeout, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT);
    request.setRetryPolicy(policy);
    requestQueue.add(request);
}
 
开发者ID:jessie345,项目名称:RealArchitecture,代码行数:17,代码来源:VolleyClient.java

示例4: callAPI

public void callAPI(View view) {
    Log.d("Action Log", "button clicked");

    RequestQueue queue = Volley.newRequestQueue(this);
    String baseURL = "http://azureml-recommend-sample-android.azurewebsites.net";//ご自身の展開した Azure Web Apps のURL を記入してください。
    String url = baseURL +  "/api/values/11";//Web application 側の API を呼び出します。この例では ID 11 の人を呼び出すことになります。


    //https://developer.android.com/intl/ja/training/volley/simple.html を参考に実装
    StringRequest apiRequest = new StringRequest(Request.Method.GET, url,
            new Response.Listener<String>() {
                @Override
                public void onResponse(String response) {
                    //成功時の出力
                    Log.d("response", response);
                }
            },
            new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    //失敗時のエラー出力。
                    Log.d("response", error.toString());
                }
            });

    int custome_timeout_ms = 60000;//timeoutを60000sec(1min)に設定する為の変数
    DefaultRetryPolicy policy = new DefaultRetryPolicy(custome_timeout_ms,DefaultRetryPolicy.DEFAULT_MAX_RETRIES,DefaultRetryPolicy.DEFAULT_BACKOFF_MULT);
    apiRequest.setRetryPolicy(policy);//リトライのポリシーを設定。ここで、タイムアウトの時間を変更。

    //API 呼び出し
    queue.add(apiRequest);
}
 
开发者ID:NT-D,项目名称:AzureML_Recommend_Android,代码行数:32,代码来源:MainActivity.java

示例5: onCreate

@Override
protected void onCreate(Bundle bundle) {
    super.onCreate(bundle);

    this.mContext = this;
    this.mApplicationContext = getApplicationContext();
    this.mActivity = this;

    this.volleyQueue = Volley.newRequestQueue(mContext);

    this.policy = new DefaultRetryPolicy(Constant.TimeInApplication.NET_TIMEOUT, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT);

    ActivityManager.addActivity(this);
}
 
开发者ID:ChinaSunHZ,项目名称:ProjectUtils,代码行数:14,代码来源:BaseActivity.java

示例6: onAttach

@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);

    mContext = activity.getBaseContext();
    mApplicationContext = mContext.getApplicationContext();
    mActivity = activity;

    this.volleyQueue = Volley.newRequestQueue(mContext);
    this.policy = new DefaultRetryPolicy(Constant.TimeInApplication.NET_TIMEOUT, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT);
}
 
开发者ID:ChinaSunHZ,项目名称:ProjectUtils,代码行数:11,代码来源:BaseFragment.java

示例7: CameraControlReq

public CameraControlReq(RequestQueue queue, OnCameraControlListener listener, Action cameraControlAction)
{
    mCameraControlAction = cameraControlAction;
    RetryPolicy retryPolicy = new DefaultRetryPolicy(
            15000,
            DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
            DefaultRetryPolicy.DEFAULT_BACKOFF_MULT);
    mGetJsonObjectReq = new PutJsonObject(queue, this, UrlRequestType.CAMERA_CONTROL, getJsonObject(), retryPolicy);
    mListener = listener;
}
 
开发者ID:ludwigandersson,项目名称:thermospy,代码行数:10,代码来源:CameraControlReq.java

示例8: init

protected void init() {
	stringRequest = new com.android.volley.toolbox.StringRequest(method, url,new Response.Listener<String>() {
		@Override
		public void onResponse(String response) {
				onSuccess(response,response);
				onEnd();
		}
	},
	new Response.ErrorListener() {
		@Override
		public void onErrorResponse(VolleyError error) {
			if (error instanceof TimeoutError) {
				LogUpdate.getInstance().addLog(LogDataUtils.FUNCTIONID_LOG_TIMEOUT,getUrl(), String.valueOf(-1), "连接超时");
			}else if ((error instanceof ServerError) || (error instanceof AuthFailureError)) {
				LogUpdate.getInstance().addLog(LogDataUtils.FUNCTIONID_LOG_TIMEOUT,getUrl(), String.valueOf(-1), "网络连接异常,请稍后再试");
			}
			onFailure(0,getErrorStr(error));
			onEnd();
		}
	}){
		@Override
		protected Map<String, String> getParams() throws AuthFailureError {
			if(params!=null&&params.entrySet().size()>0){
				return validFormat(params);
			}
			return super.getParams();
		}
		@Override
		public Map<String, String> getHeaders() throws AuthFailureError {
			return NetConfig.getHeaders(isNormalPost);
		}
		@Override
		public RetryPolicy getRetryPolicy() {
			RetryPolicy retryPolicy = new DefaultRetryPolicy(NetConfig.getConnectionTimeout(), DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT);
			return retryPolicy;
		}
	};
}
 
开发者ID:simplelifetian,项目名称:GomeOnline,代码行数:38,代码来源:StringRequest.java

示例9: MultiPartRequest

public MultiPartRequest(int method, String url, Listener<T> listener, ErrorListener errorlistener) {

        super(method, url, errorlistener, new DefaultRetryPolicy(TIMEOUT_MS, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
        mListener = listener;
        mMultipartParams = new HashMap<String, MultiPartRequest.MultiPartParam>();
        mFileUploads = new HashMap<String, String>();
        
    }
 
开发者ID:barterli,项目名称:barterli_android,代码行数:8,代码来源:MultiPartRequest.java

示例10: initiateResetPasswordProcess

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,代码行数:58,代码来源:ForgotActivity.java

示例11: updateLocationDB

public void updateLocationDB() {
    Gson gson = new Gson();
    String json = sharedPreferencesProfileInformation.getString("currentUser", "");
    currentUser = gson.fromJson(json, User.class);
    CustomLocation customLocation = new CustomLocation(mLatitude,currentUser.getId(),mLongitude);
    String postUser = gson.toJson(customLocation, CustomLocation.class);

    JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(
            Request.Method.POST,
            AppConfig.MAP_URL_SEND,
            postUser,
            new Response.Listener<JSONObject>() {
                @Override
                public void onResponse(JSONObject jsonObject) {
                    try {
                        Log.d("RESPONSE", jsonObject.toString());
                        //TODO parse response
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            },
            new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    error.printStackTrace();
                }
            }
    ){
        @Override
        public Map<String, String> getHeaders() throws AuthFailureError {
            super.getHeaders();
            HashMap<String, String> headers = new HashMap<String, String>();
            headers.put("Content-Type", "application/json");
            headers.put("charset", "utf-8");
            headers.put("abc",currentUser.getAuthToken());
            return headers;
        }
    };

    int socketTimeout = 10000;
    RetryPolicy policy = new DefaultRetryPolicy(socketTimeout, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT);
    jsonObjectRequest.setRetryPolicy(policy);
    MySingleton.getInstance(MainMenuActivity.this).addToRequestQueue(jsonObjectRequest);
}
 
开发者ID:Amay-Mishra,项目名称:Trackr,代码行数:45,代码来源:MainMenuActivity.java

示例12: getRetryPolicy

public static DefaultRetryPolicy getRetryPolicy() {
    return new DefaultRetryPolicy(
            5000,
            DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
            DefaultRetryPolicy.DEFAULT_BACKOFF_MULT);
}
 
开发者ID:dylanmaryk,项目名称:InsanityRadio-Android,代码行数:6,代码来源:DataModel.java

示例13: getRetryPolicy

@Override
public RetryPolicy getRetryPolicy() {
    RetryPolicy retryPolicy = new DefaultRetryPolicy(Constant.SOCKET_TIMEOUT, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT);
    return retryPolicy;
}
 
开发者ID:tengbinlive,项目名称:ooooim_android,代码行数:5,代码来源:CommonRequest.java

示例14: getInstance

public static DefaultRetryPolicy getInstance(){
    return new DefaultRetryPolicy(MY_TIME_OUT,DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT);
}
 
开发者ID:chicobentojr,项目名称:minhaeiro,代码行数:3,代码来源:MinhaeiroRetryPolicy.java

示例15: getRetryPolicy

@Override
public RetryPolicy getRetryPolicy() {
    return new DefaultRetryPolicy(Constant.SOCKET_TIMEOUT, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT);
}
 
开发者ID:tengbinlive,项目名称:aibao_demo,代码行数:4,代码来源:CommonRequest.java


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