können Sie die JsonRequest vorbei folgenden Code verwenden.
JsonObjectRequest req = new JsonObjectRequest(Url, new JSONObject(),
new com.android.volley.Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
try {
Log.v("Response:%n %s", response.toString(0));
JSONObject jsonObject = new JSONObject(response.toString());
String success = jsonObject.getString("success");
// Get your Token Here.
} catch (JSONException e) {
e.printStackTrace();
Toast.makeText(LoginActivity.this, "Server or Connection Error.", Toast.LENGTH_SHORT).show();
builder.dismiss();
}
}
}, new com.android.volley.Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
VolleyLog.e("Error: ", error.getMessage());
}
});
AppController.getInstance().addToRequestQueue(req);
Um die Anfrage in Volley passieren Sie AppController
Klasse benötigen.
public class AppController extends Application {
public static final String TAG = AppController.class.getSimpleName();
private RequestQueue mRequestQueue;
private static AppController mInstance;
@Override
public void onCreate() {
super.onCreate();
mInstance = this;
}
public static synchronized AppController getInstance(){
return mInstance;
}
public RequestQueue getRequestQueue(){
if(mRequestQueue == null){
mRequestQueue = Volley.newRequestQueue(getApplicationContext());
}
return mRequestQueue;
}
public <T> void addToRequestQueue(Request<T> req, String tag) {
// set the default tag if tag is empty
req.setTag(TextUtils.isEmpty(tag) ? TAG : tag);
getRequestQueue().add(req);
}
public <T> void addToRequestQueue(Request<T> req) {
req.setTag(TAG);
getRequestQueue().add(req);
}
public void cancelPendingRequests(Object tag) {
if (mRequestQueue != null) {
mRequestQueue.cancelAll(tag);
}
}
}
https://developer.android.com/training/volley/request.html#request-json – BNK
Ich glaube, Sie Lösung finden Sie hier http://stackoverflow.com/questions/31230308/way-to -pass-long-parameter-in-url-request-using-volley Hoffe, das wird dir helfen – Vij