本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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&¶ms.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;
}
};
}
示例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>();
}
示例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);
}
示例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);
}
示例12: getRetryPolicy
public static DefaultRetryPolicy getRetryPolicy() {
return new DefaultRetryPolicy(
5000,
DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
DefaultRetryPolicy.DEFAULT_BACKOFF_MULT);
}
示例13: getRetryPolicy
@Override
public RetryPolicy getRetryPolicy() {
RetryPolicy retryPolicy = new DefaultRetryPolicy(Constant.SOCKET_TIMEOUT, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT);
return retryPolicy;
}
示例14: getInstance
public static DefaultRetryPolicy getInstance(){
return new DefaultRetryPolicy(MY_TIME_OUT,DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT);
}
示例15: getRetryPolicy
@Override
public RetryPolicy getRetryPolicy() {
return new DefaultRetryPolicy(Constant.SOCKET_TIMEOUT, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT);
}