當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。