本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}