Codota Logo
JsonObjectRequest
Code IndexAdd Codota to your IDE (free)

How to use
JsonObjectRequest
in
com.android.volley.toolbox

Best Java code snippets using com.android.volley.toolbox.JsonObjectRequest (Showing top 20 results out of 315)

  • Common ways to obtain JsonObjectRequest
private void myMethod () {
JsonObjectRequest j =
  • Codota IconString str;new JsonObjectRequest(str, null, null, null)
  • Smart code suggestions by Codota
}
origin: jiangqqlmj/FastDev4Android

/**
 * 请求返回JSONObject对象 Get请求 无参数,或者get请求的参数直接拼接在URL上面
 * @param url   请求地址
 * @param listener  数据回调接口
 */
public void get(String url, final Fdv_CallBackListener<JSONObject> listener){
  JsonObjectRequest jsonObjectRequest=new JsonObjectRequest(Request.Method.GET, url, null, new Response.Listener<JSONObject>() {
    @Override
    public void onResponse(JSONObject response) {
        if(listener!=null){
          listener.onSuccessResponse(response);
        }
    }
  }, new Response.ErrorListener() {
    @Override
    public void onErrorResponse(VolleyError error) {
      if(listener!=null){
        listener.onErrorResponse(error);
      }
    }
  });
  addRequest(jsonObjectRequest);
}
origin: mcxiaoke/android-volley

@Test public void specifiedCharsetJsonObject() throws Exception {
  byte[] data = jsonObjectString().getBytes(Charset.forName("ISO-8859-1"));
  Map<String, String> headers = new HashMap<String, String>();
  headers.put("Content-Type", "application/json; charset=iso-8859-1");
  NetworkResponse network = new NetworkResponse(data, headers);
  JsonObjectRequest objectRequest = new JsonObjectRequest("", null, null, null);
  Response<JSONObject> objectResponse = objectRequest.parseNetworkResponse(network);
  assertNotNull(objectResponse);
  assertTrue(objectResponse.isSuccess());
  //don't check the text in Czech, ISO-8859-1 doesn't support some Czech characters
  assertEquals(COPY_VALUE, objectResponse.result.getString(COPY_NAME));
}
origin: xuningjack/AndroidNet

/**
 * get请求jsonobject
 */
private void volleyJsonObjectGet(){
  Response.Listener<JSONObject> listener = new Response.Listener<JSONObject>() {
    @Override
    public void onResponse(JSONObject response) {
      Toast.makeText(getApplicationContext(), response.toString(), Toast.LENGTH_LONG).show();
      Log.d(TAG, "JSONObject-----------" + response.toString());
    }
  };
  JsonObjectRequest request = new JsonObjectRequest(Method.GET, url, null, listener, errorListener);
  request.setTag("jackJsonObjectRequest");
  MyApplication.getHttpRequestQueue().add(request);
}
origin: brainysoon/cyberCar

private void pullUpdateInfo() {
  //用Volley请求服务器最新的版本信息
  JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(AUTO_UPDATE_SERVER_ADDRESS, null, new Response.Listener<JSONObject>() {
    @Override
    public void onResponse(JSONObject jsonObject) {
      paserJsonData(jsonObject);
    }
  }, new Response.ErrorListener() {
    @Override
    public void onErrorResponse(VolleyError volleyError) {
      volleyError.printStackTrace();
      afterUpdate.toDoAfterUpdate();
    }
  });
  //设置超时时间,以及重复请求次数
  jsonObjectRequest.setRetryPolicy(new DefaultRetryPolicy(500, 0, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
  //设置Tag
  jsonObjectRequest.setTag(AUTO_UPDATE_SERVER_ADDRESS);
  //添加到请求队列里面
  MyApplication.getRequestQueue().add(jsonObjectRequest);
}
origin: InnoFang/Android-Code-Demos

private String volleyGetJsonObjectRequest() {
  JsonObjectRequest request = new JsonObjectRequest(Request.Method.GET, Constant.JUHE_URL_GET, null, // 用post方式时,需更改为带请求参数的Object
      new Response.Listener<JSONObject>() {
        @Override
        public void onResponse(JSONObject response) {
          Toast.makeText(MainActivity.this, response.toString(), Toast.LENGTH_SHORT).show();
        }
  },
      new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
          Toast.makeText(MainActivity.this, error.toString(), Toast.LENGTH_SHORT).show();
        }
    });
  request.setTag(JSON_OBJECT_GET_TAG);
  MyApplication.getHttpQueues().add(request);
  return request.getTag().toString();
}
origin: msahakyan/nested-recycler-view

JsonObjectRequest jsonRequest = new JsonObjectRequest(method, endpoint.toString(), null,
  new Response.Listener<JSONObject>() {
    @Override
jsonRequest.setRetryPolicy(new CustomRetryPolicy(REQUEST_TIMEOUT, MAX_RETRIES, BACKOFF_MULTIPLIER));
origin: AnandChowdhary/saga-android

  progressDialog.show();
JsonObjectRequest request = new JsonObjectRequest(Request.Method.GET, updateUrl, null, new Response.Listener<JSONObject>() {
  @Override
  public void onResponse(JSONObject response) {
request.setShouldCache(false);
VolleySingleton.getInstance(context).getRequestQueue().add(request);
origin: alirezaafkar/JsonRequester

  mBuilder.timeOut = DefaultRetryPolicy.DEFAULT_TIMEOUT_MS;
request.setShouldCache(mBuilder.shouldCache);
request.setRetryPolicy(new DefaultRetryPolicy(mBuilder.timeOut
    , mBuilder.retry, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
request.setTag(mBuilder.tag);
mQueue.add(request);
origin: domoticz/domoticz-android

  @Override
  protected Response<JSONObject> parseNetworkResponse(NetworkResponse response) {
    // since we don't know which of the two underlying network vehicles
    // will Volley use, we have to handle and store session cookies manually
    sessionUtil.checkSessionCookie(response.headers);
    return super.parseNetworkResponse(response);
  }
};
origin: SkyTreasure/Airbnb-Android-Google-Map-View

int socketTimeout = 5000;//30 seconds - change to what you want
RetryPolicy policy = new DefaultRetryPolicy(socketTimeout, 2, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT);
jsObjRequest.setRetryPolicy(policy);
CustomVolleyRequestQueue.getInstance(mContext).getRequestQueue().add(jsObjRequest);
origin: multidots/android-social-signin-helper

private void request(@NonNull Context context, int method, @NonNull String url, @Nullable JSONObject body, @Nullable ApiListener apiListener) {
  LISession session = LISessionManager.getInstance(context.getApplicationContext()).getSession();
  if (!session.isValid()) {
    if (apiListener != null) {
      apiListener.onApiError(new LIApiError(LIApiError.ErrorType.accessTokenIsNotSet, "access toke is not set", null));
    }
    return;
  }
  JsonObjectRequest jsonObjectRequest = buildRequest(session.getAccessToken().getValue(), method, url, body, apiListener);
  jsonObjectRequest.setTag(context == null ? TAG : context);
  QueueManager.getInstance(context).getRequestQueue().add(jsonObjectRequest);
}
origin: brainysoon/cyberCar

/**
 * *********************************************************************************************
 * 查询订单请求
 */
public static void sendMyOrdersPost(JSONObject mParams, final handMyOrdersPost mHand) {
  JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, MY_ORDERS_POST_URL,
      mParams, new Response.Listener<JSONObject>() {
    @Override
    public void onResponse(JSONObject jsonObject) {
      mHand.handMyOrdersPostResult(jsonObject);
    }
  }, new Response.ErrorListener() {
    @Override
    public void onErrorResponse(VolleyError volleyError) {
      mHand.handMyOrdersPostError(volleyError);
    }
  });
  //setTag
  jsonObjectRequest.setTag(MY_ORDERS_POST_TAG);
  //add
  MyApplication.getRequestQueue().add(jsonObjectRequest);
}
origin: InnoFang/Android-Code-Demos

private String volleyPostJsonObjectRequest() {
  HashMap<String, String> hashMap = new HashMap<>();
  hashMap.put("phone", "13429667914");
  hashMap.put("key", Constant.JUHE_API_KEY);
  JSONObject object = new JSONObject(hashMap);
  JsonObjectRequest request = new JsonObjectRequest(Request.Method.POST, Constant.JUHE_URL_POST, object,
      new Response.Listener<JSONObject>() {
        @Override
        public void onResponse(JSONObject response) {
          Toast.makeText(MainActivity.this, response.toString(), Toast.LENGTH_SHORT).show();
        }
      },
      new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
          Toast.makeText(MainActivity.this, error.toString(), Toast.LENGTH_SHORT).show();
        }
      });
  request.setTag(JSON_OBJECT_POST_TAG);
  MyApplication.getHttpQueues().add(request);
  return request.getTag().toString();
}
origin: Odoo-mobile/framework

  JsonObjectRequest request = new JsonObjectRequest(url, postData, OdooWrapper.this, errorListener);
  request.setRetryPolicy(new DefaultRetryPolicy(new_request_timeout, new_request_max_retry,
      DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
  requestQueue.add(request);
} else {
  JsonObjectRequest request = new JsonObjectRequest(url, postData, requestFuture, requestFuture);
  request.setRetryPolicy(new DefaultRetryPolicy(new_request_timeout, new_request_max_retry,
      DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
  requestQueue.add(request);
origin: pinterest/android-pdk

@Override
protected Response<JSONObject> parseNetworkResponse(NetworkResponse response) {
  _callback.setResponseHeaders(response.headers);
  _callback.setStatusCode(response.statusCode);
  return super.parseNetworkResponse(response);
}
origin: rajeeviiit/AndroidProject

jsonObjectRequest.setRetryPolicy(new DefaultRetryPolicy(50000,DefaultRetryPolicy.DEFAULT_MAX_RETRIES,DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
origin: jiangqqlmj/FastDev4Android

/**
 * 发送POST请求, 返回JSONObject对象数据
 * @param url    请求地址
 * @param listener  数据返回回调接口
 * @param params   POST请求参数
 */
public void post(String url, final Fdv_CallBackListener<JSONObject> listener,Map<String,String> params){
  JsonObjectRequest jsonObjectRequest=new JsonObjectRequest(Request.Method.POST, url, null, new Response.Listener<JSONObject>() {
    @Override
    public void onResponse(JSONObject response) {
      if(listener!=null){
        listener.onSuccessResponse(response);
      }
    }
  }, new Response.ErrorListener() {
    @Override
    public void onErrorResponse(VolleyError error) {
      if(listener!=null){
        listener.onErrorResponse(error);
      }
    }
  });
  addRequest(jsonObjectRequest,params);
}
origin: jiangqqlmj/FastDev4Android

@Test public void specifiedCharsetJsonObject() throws Exception {
  byte[] data = jsonObjectString().getBytes(Charset.forName("ISO-8859-1"));
  Map<String, String> headers = new HashMap<String, String>();
  headers.put("Content-Type", "application/json; charset=iso-8859-1");
  NetworkResponse network = new NetworkResponse(data, headers);
  JsonObjectRequest objectRequest = new JsonObjectRequest("", null, null, null);
  Response<JSONObject> objectResponse = objectRequest.parseNetworkResponse(network);
  assertNotNull(objectResponse);
  assertTrue(objectResponse.isSuccess());
  //don't check the text in Czech, ISO-8859-1 doesn't support some Czech characters
  assertEquals(COPY_VALUE, objectResponse.result.getString(COPY_NAME));
}
origin: brainysoon/cyberCar

/**
 * **********************************************************************************************
 * 得到用户的  汽车列表
 */
public static void sendCarInfoPost(JSONObject mParams, final canHandCarInfosPostResult mHand) {
  JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, CAR_INFO_POST_URL, mParams,
      new Response.Listener<JSONObject>() {
        @Override
        public void onResponse(JSONObject jsonObject) {
          mHand.handCarInfosPostResutl(jsonObject);
        }
      }, new Response.ErrorListener() {
    @Override
    public void onErrorResponse(VolleyError volleyError) {
      mHand.handCarInfosPostError(volleyError);
    }
  });
  //setTag
  jsonObjectRequest.setTag(CAR_INFO_POST_TAG);
  //add
  MyApplication.getRequestQueue().add(jsonObjectRequest);
}
origin: kaushikgopal/RxJava-Android-Samples

/**
 * Converts the Asynchronous Request into a Synchronous Future that can be used to block via
 * {@code Future.get()}. Observables require blocking/synchronous functions
 *
 * @return JSONObject
 * @throws ExecutionException
 * @throws InterruptedException
 */
private JSONObject getRouteData() throws ExecutionException, InterruptedException {
 RequestFuture<JSONObject> future = RequestFuture.newFuture();
 String url = "http://www.weather.com.cn/adat/sk/101010100.html";
 JsonObjectRequest req = new JsonObjectRequest(Request.Method.GET, url, future, future);
 MyVolley.getRequestQueue().add(req);
 return future.get();
}
com.android.volley.toolboxJsonObjectRequest

Javadoc

A request for retrieving a JSONObject response body at a given URL, allowing for an optional JSONObject to be passed in as part of the request body.

Most used methods

  • <init>
    Constructor which defaults to GET if jsonRequest isnull, POST otherwise.
  • parseNetworkResponse
  • setRetryPolicy
  • setTag
  • getHeaders
  • setShouldCache
  • getBody
  • getParamsEncoding
  • getTag

Popular in Java

  • Making http requests using okhttp
  • putExtra (Intent)
  • compareTo (BigDecimal)
    Compares this BigDecimal with the specified BigDecimal. Two BigDecimal objects that are equal in val
  • getSupportFragmentManager (FragmentActivity)
    Return the FragmentManager for interacting with fragments associated with this activity.
  • ObjectMapper (com.fasterxml.jackson.databind)
    This mapper (or, data binder, or codec) provides functionality for converting between Java objects (
  • Kernel (java.awt.image)
  • Connection (java.sql)
    A connection represents a link from a Java application to a database. All SQL statements and results
  • Locale (java.util)
    A Locale object represents a specific geographical, political, or cultural region. An operation that
  • SortedMap (java.util)
    A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
  • IOUtils (org.apache.commons.io)
    General IO stream manipulation utilities. This class provides static utility methods for input/outpu
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now