Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void postData(String relay, String status) {
- RequestQueue requestQueue = Volley.newRequestQueue(getContext());
- // Enter the correct url for your api service site
- try {
- JSONObject object = new JSONObject("{}");
- //input your API parameters
- object.put("relay",relay);
- object.put("status",status);
- object.put("sn",sn);
- JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, "http://"+server+"/relay", object,
- new Response.Listener<JSONObject>() {
- @Override
- public void onResponse(JSONObject response) {
- Log.e(" POST", "Message: "+response.toString());
- try {
- } catch (Exception e){
- }
- }
- }, new Response.ErrorListener() {
- @Override
- public void onErrorResponse(VolleyError error) {
- Log.e("ErrorPOST", "Message: "+error.toString());
- }
- });
- requestQueue.add(jsonObjectRequest);
- } catch (Exception e) {
- e.printStackTrace();
- Log.e("Catch POST", e.toString());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement