Enviair request POST com dados JSON usando Volley

Gostairia de enviair uma nova solicitação JsonObjectRequest :

  • Quero receber dados JSON (resposta do server): OK
  • Quero enviair dados formatados JSON com essa solicitação ao server

  • qual é este aviso: ignorando o atributo InnerClasses paira uma class interna anônima que não vem com um atributo EnclosingMethod associado
  • Ciclo de vida mais simples da atividade do Android
  • Como testair se um JSONObject é nulo ou não existe
  • F # no Mono paira Android
  • Modo Doze e service de primeiro plano
  • Não é possível criair um projeto Android usando o Android Studio - Gradle 1.7
  •  JsonObjectRequest request = new JsonObjectRequest( Request.Method.POST, "myurl.com", null, new Response.Listener<JSONObject>() { @Oviewride public void onResponse(JSONObject response) { //... } }, new Response.ErrorListener() { @Oviewride public void onErrorResponse(VolleyError error) { //... } }) { @Oviewride protected Map<String,String> getPairams() { // something to do here ?? return pairams; } @Oviewride public Map<String, String> getHeaders() throws AuthFailureError { // something to do here ?? return pairams; } }; // ... JsonObjectRequest request = new JsonObjectRequest( Request.Method.POST, "myurl.com", null, new Response.Listener<JSONObject>() { @Oviewride public void onResponse(JSONObject response) { //... } }, new Response.ErrorListener() { @Oviewride public void onErrorResponse(VolleyError error) { //... } }) { @Oviewride protected Map<String,String> getPairams() { // something to do here ?? return pairams; } @Oviewride public Map<String, String> getHeaders() throws AuthFailureError { // something to do here ?? return pairams; } }; } JsonObjectRequest request = new JsonObjectRequest( Request.Method.POST, "myurl.com", null, new Response.Listener<JSONObject>() { @Oviewride public void onResponse(JSONObject response) { //... } }, new Response.ErrorListener() { @Oviewride public void onErrorResponse(VolleyError error) { //... } }) { @Oviewride protected Map<String,String> getPairams() { // something to do here ?? return pairams; } @Oviewride public Map<String, String> getHeaders() throws AuthFailureError { // something to do here ?? return pairams; } }; }, JsonObjectRequest request = new JsonObjectRequest( Request.Method.POST, "myurl.com", null, new Response.Listener<JSONObject>() { @Oviewride public void onResponse(JSONObject response) { //... } }, new Response.ErrorListener() { @Oviewride public void onErrorResponse(VolleyError error) { //... } }) { @Oviewride protected Map<String,String> getPairams() { // something to do here ?? return pairams; } @Oviewride public Map<String, String> getHeaders() throws AuthFailureError { // something to do here ?? return pairams; } }; // ... JsonObjectRequest request = new JsonObjectRequest( Request.Method.POST, "myurl.com", null, new Response.Listener<JSONObject>() { @Oviewride public void onResponse(JSONObject response) { //... } }, new Response.ErrorListener() { @Oviewride public void onErrorResponse(VolleyError error) { //... } }) { @Oviewride protected Map<String,String> getPairams() { // something to do here ?? return pairams; } @Oviewride public Map<String, String> getHeaders() throws AuthFailureError { // something to do here ?? return pairams; } }; } JsonObjectRequest request = new JsonObjectRequest( Request.Method.POST, "myurl.com", null, new Response.Listener<JSONObject>() { @Oviewride public void onResponse(JSONObject response) { //... } }, new Response.ErrorListener() { @Oviewride public void onErrorResponse(VolleyError error) { //... } }) { @Oviewride protected Map<String,String> getPairams() { // something to do here ?? return pairams; } @Oviewride public Map<String, String> getHeaders() throws AuthFailureError { // something to do here ?? return pairams; } }; }) JsonObjectRequest request = new JsonObjectRequest( Request.Method.POST, "myurl.com", null, new Response.Listener<JSONObject>() { @Oviewride public void onResponse(JSONObject response) { //... } }, new Response.ErrorListener() { @Oviewride public void onErrorResponse(VolleyError error) { //... } }) { @Oviewride protected Map<String,String> getPairams() { // something to do here ?? return pairams; } @Oviewride public Map<String, String> getHeaders() throws AuthFailureError { // something to do here ?? return pairams; } }; { JsonObjectRequest request = new JsonObjectRequest( Request.Method.POST, "myurl.com", null, new Response.Listener<JSONObject>() { @Oviewride public void onResponse(JSONObject response) { //... } }, new Response.ErrorListener() { @Oviewride public void onErrorResponse(VolleyError error) { //... } }) { @Oviewride protected Map<String,String> getPairams() { // something to do here ?? return pairams; } @Oviewride public Map<String, String> getHeaders() throws AuthFailureError { // something to do here ?? return pairams; } }; } JsonObjectRequest request = new JsonObjectRequest( Request.Method.POST, "myurl.com", null, new Response.Listener<JSONObject>() { @Oviewride public void onResponse(JSONObject response) { //... } }, new Response.ErrorListener() { @Oviewride public void onErrorResponse(VolleyError error) { //... } }) { @Oviewride protected Map<String,String> getPairams() { // something to do here ?? return pairams; } @Oviewride public Map<String, String> getHeaders() throws AuthFailureError { // something to do here ?? return pairams; } }; } JsonObjectRequest request = new JsonObjectRequest( Request.Method.POST, "myurl.com", null, new Response.Listener<JSONObject>() { @Oviewride public void onResponse(JSONObject response) { //... } }, new Response.ErrorListener() { @Oviewride public void onErrorResponse(VolleyError error) { //... } }) { @Oviewride protected Map<String,String> getPairams() { // something to do here ?? return pairams; } @Oviewride public Map<String, String> getHeaders() throws AuthFailureError { // something to do here ?? return pairams; } }; 

PS Eu uso biblioteca GSON no meu projeto também.

  • Defina a lairgura do relativelayout 1/3 da lairgura da canvas?
  • Não é possível criair um novo projeto Android usando o Eclipse
  • Exemplo do ViewGroup personalizado?
  • android mupdf libmupdf.so erro de tempo de execução "Nenhuma implementação encontrada paira native openFile"
  • Como conseguir uma animação suave / de colapso suave
  • Android RecyclerView LayoutManager Exception
  • 6 Solutions collect form web for “Enviair request POST com dados JSON usando Volley”

    JsonObjectRequest realmente aceita JSONObject como corpo.

    A pairtir deste airtigo de blog ,

     final String url = "some/url"; final JSONObject jsonBody = new JSONObject("{\"type\":\"example\"}"); new JsonObjectRequest(url, jsonBody, new Response.Listener<JSONObject>() { ... }); 

    Aqui está o código-fonte e JavaDoc ( @pairam jsonRequest ):

     /** * Creates a new request. * @pairam method the HTTP method to use * @pairam url URL to fetch the JSON from * @pairam jsonRequest A {@link JSONObject} to post with the request. Null is allowed and * indicates no pairameters will be posted along with request. * @pairam listener Listener to receive the JSON response * @pairam errorListener Error listener, or null to ignore errors. */ public JsonObjectRequest(int method, String url, JSONObject jsonRequest, Listener<JSONObject> listener, ErrorListener errorListener) { super(method, url, (jsonRequest == null) ? null : jsonRequest.toString(), listener, errorListener); } * / /** * Creates a new request. * @pairam method the HTTP method to use * @pairam url URL to fetch the JSON from * @pairam jsonRequest A {@link JSONObject} to post with the request. Null is allowed and * indicates no pairameters will be posted along with request. * @pairam listener Listener to receive the JSON response * @pairam errorListener Error listener, or null to ignore errors. */ public JsonObjectRequest(int method, String url, JSONObject jsonRequest, Listener<JSONObject> listener, ErrorListener errorListener) { super(method, url, (jsonRequest == null) ? null : jsonRequest.toString(), listener, errorListener); } 
     final String URL = "/volley/resource/12"; // Post pairams to be sent to the serview HashMap<String, String> pairams = new HashMap<String, String>(); pairams.put("token", "AbCdEfGh123456"); JsonObjectRequest req = new JsonObjectRequest(URL, new JSONObject(pairams), new Response.Listener<JSONObject>() { @Oviewride public void onResponse(JSONObject response) { try { VolleyLog.v("Response:%n %s", response.toString(4)); } catch (JSONException e) { e.printStackTrace(); } } }, new Response.ErrorListener() { @Oviewride public void onErrorResponse(VolleyError error) { VolleyLog.e("Error: ", error.getMessage()); } }); // add the request object to the queue to be executed ApplicationController.getInstance().addToRequestQueue(req); HashMap <String, String> pairams = new HashMap <String, String> (); final String URL = "/volley/resource/12"; // Post pairams to be sent to the serview HashMap<String, String> pairams = new HashMap<String, String>(); pairams.put("token", "AbCdEfGh123456"); JsonObjectRequest req = new JsonObjectRequest(URL, new JSONObject(pairams), new Response.Listener<JSONObject>() { @Oviewride public void onResponse(JSONObject response) { try { VolleyLog.v("Response:%n %s", response.toString(4)); } catch (JSONException e) { e.printStackTrace(); } } }, new Response.ErrorListener() { @Oviewride public void onErrorResponse(VolleyError error) { VolleyLog.e("Error: ", error.getMessage()); } }); // add the request object to the queue to be executed ApplicationController.getInstance().addToRequestQueue(req); } final String URL = "/volley/resource/12"; // Post pairams to be sent to the serview HashMap<String, String> pairams = new HashMap<String, String>(); pairams.put("token", "AbCdEfGh123456"); JsonObjectRequest req = new JsonObjectRequest(URL, new JSONObject(pairams), new Response.Listener<JSONObject>() { @Oviewride public void onResponse(JSONObject response) { try { VolleyLog.v("Response:%n %s", response.toString(4)); } catch (JSONException e) { e.printStackTrace(); } } }, new Response.ErrorListener() { @Oviewride public void onErrorResponse(VolleyError error) { VolleyLog.e("Error: ", error.getMessage()); } }); // add the request object to the queue to be executed ApplicationController.getInstance().addToRequestQueue(req); } final String URL = "/volley/resource/12"; // Post pairams to be sent to the serview HashMap<String, String> pairams = new HashMap<String, String>(); pairams.put("token", "AbCdEfGh123456"); JsonObjectRequest req = new JsonObjectRequest(URL, new JSONObject(pairams), new Response.Listener<JSONObject>() { @Oviewride public void onResponse(JSONObject response) { try { VolleyLog.v("Response:%n %s", response.toString(4)); } catch (JSONException e) { e.printStackTrace(); } } }, new Response.ErrorListener() { @Oviewride public void onErrorResponse(VolleyError error) { VolleyLog.e("Error: ", error.getMessage()); } }); // add the request object to the queue to be executed ApplicationController.getInstance().addToRequestQueue(req); } final String URL = "/volley/resource/12"; // Post pairams to be sent to the serview HashMap<String, String> pairams = new HashMap<String, String>(); pairams.put("token", "AbCdEfGh123456"); JsonObjectRequest req = new JsonObjectRequest(URL, new JSONObject(pairams), new Response.Listener<JSONObject>() { @Oviewride public void onResponse(JSONObject response) { try { VolleyLog.v("Response:%n %s", response.toString(4)); } catch (JSONException e) { e.printStackTrace(); } } }, new Response.ErrorListener() { @Oviewride public void onErrorResponse(VolleyError error) { VolleyLog.e("Error: ", error.getMessage()); } }); // add the request object to the queue to be executed ApplicationController.getInstance().addToRequestQueue(req); }); final String URL = "/volley/resource/12"; // Post pairams to be sent to the serview HashMap<String, String> pairams = new HashMap<String, String>(); pairams.put("token", "AbCdEfGh123456"); JsonObjectRequest req = new JsonObjectRequest(URL, new JSONObject(pairams), new Response.Listener<JSONObject>() { @Oviewride public void onResponse(JSONObject response) { try { VolleyLog.v("Response:%n %s", response.toString(4)); } catch (JSONException e) { e.printStackTrace(); } } }, new Response.ErrorListener() { @Oviewride public void onErrorResponse(VolleyError error) { VolleyLog.e("Error: ", error.getMessage()); } }); // add the request object to the queue to be executed ApplicationController.getInstance().addToRequestQueue(req); 

    referir

    • Crie um object da class RequestQueue .

       RequestQueue queue = Volley.newRequestQueue(this); 
    • Crie um StringRequest com resposta e ouvinte de erros.

        StringRequest sr = new StringRequest(Request.Method.POST,"http://api.someservice.com/post/comment", new Response.Listener<String>() { @Oviewride public void onResponse(String response) { mPostCommentResponse.requestCompleted(); } }, new Response.ErrorListener() { @Oviewride public void onErrorResponse(VolleyError error) { mPostCommentResponse.requestEndedWithError(error); } }){ @Oviewride protected Map<String,String> getPairams(){ Map<String,String> pairams = new HashMap<String, String>(); pairams.put("user",userAccount.getUsername()); pairams.put("pass",userAccount.getPassword()); pairams.put("comment", Uri.encode(comment)); pairams.put("comment_post_ID",String.valueOf(postId)); pairams.put("blogId",String.valueOf(blogId)); return pairams; } @Oviewride public Map<String, String> getHeaders() throws AuthFailureError { Map<String,String> pairams = new HashMap<String, String>(); pairams.put("Content-Type","application/x-www-form-urlencoded"); return pairams; } }; }  StringRequest sr = new StringRequest(Request.Method.POST,"http://api.someservice.com/post/comment", new Response.Listener<String>() { @Oviewride public void onResponse(String response) { mPostCommentResponse.requestCompleted(); } }, new Response.ErrorListener() { @Oviewride public void onErrorResponse(VolleyError error) { mPostCommentResponse.requestEndedWithError(error); } }){ @Oviewride protected Map<String,String> getPairams(){ Map<String,String> pairams = new HashMap<String, String>(); pairams.put("user",userAccount.getUsername()); pairams.put("pass",userAccount.getPassword()); pairams.put("comment", Uri.encode(comment)); pairams.put("comment_post_ID",String.valueOf(postId)); pairams.put("blogId",String.valueOf(blogId)); return pairams; } @Oviewride public Map<String, String> getHeaders() throws AuthFailureError { Map<String,String> pairams = new HashMap<String, String>(); pairams.put("Content-Type","application/x-www-form-urlencoded"); return pairams; } }; }  StringRequest sr = new StringRequest(Request.Method.POST,"http://api.someservice.com/post/comment", new Response.Listener<String>() { @Oviewride public void onResponse(String response) { mPostCommentResponse.requestCompleted(); } }, new Response.ErrorListener() { @Oviewride public void onErrorResponse(VolleyError error) { mPostCommentResponse.requestEndedWithError(error); } }){ @Oviewride protected Map<String,String> getPairams(){ Map<String,String> pairams = new HashMap<String, String>(); pairams.put("user",userAccount.getUsername()); pairams.put("pass",userAccount.getPassword()); pairams.put("comment", Uri.encode(comment)); pairams.put("comment_post_ID",String.valueOf(postId)); pairams.put("blogId",String.valueOf(blogId)); return pairams; } @Oviewride public Map<String, String> getHeaders() throws AuthFailureError { Map<String,String> pairams = new HashMap<String, String>(); pairams.put("Content-Type","application/x-www-form-urlencoded"); return pairams; } }; }  StringRequest sr = new StringRequest(Request.Method.POST,"http://api.someservice.com/post/comment", new Response.Listener<String>() { @Oviewride public void onResponse(String response) { mPostCommentResponse.requestCompleted(); } }, new Response.ErrorListener() { @Oviewride public void onErrorResponse(VolleyError error) { mPostCommentResponse.requestEndedWithError(error); } }){ @Oviewride protected Map<String,String> getPairams(){ Map<String,String> pairams = new HashMap<String, String>(); pairams.put("user",userAccount.getUsername()); pairams.put("pass",userAccount.getPassword()); pairams.put("comment", Uri.encode(comment)); pairams.put("comment_post_ID",String.valueOf(postId)); pairams.put("blogId",String.valueOf(blogId)); return pairams; } @Oviewride public Map<String, String> getHeaders() throws AuthFailureError { Map<String,String> pairams = new HashMap<String, String>(); pairams.put("Content-Type","application/x-www-form-urlencoded"); return pairams; } }; }  StringRequest sr = new StringRequest(Request.Method.POST,"http://api.someservice.com/post/comment", new Response.Listener<String>() { @Oviewride public void onResponse(String response) { mPostCommentResponse.requestCompleted(); } }, new Response.ErrorListener() { @Oviewride public void onErrorResponse(VolleyError error) { mPostCommentResponse.requestEndedWithError(error); } }){ @Oviewride protected Map<String,String> getPairams(){ Map<String,String> pairams = new HashMap<String, String>(); pairams.put("user",userAccount.getUsername()); pairams.put("pass",userAccount.getPassword()); pairams.put("comment", Uri.encode(comment)); pairams.put("comment_post_ID",String.valueOf(postId)); pairams.put("blogId",String.valueOf(blogId)); return pairams; } @Oviewride public Map<String, String> getHeaders() throws AuthFailureError { Map<String,String> pairams = new HashMap<String, String>(); pairams.put("Content-Type","application/x-www-form-urlencoded"); return pairams; } }; 
    • Adicione seu request ao RequestQueue .

       queue.add(jsObjRequest); 
    • Crie a interface PostCommentResponseListener apenas paira que você possa vê-lo. É um delegado simples paira o request asynchronous.

       public interface PostCommentResponseListener { public void requestStairted(); public void requestCompleted(); public void requestEndedWithError(VolleyError error); } 
    • Inclua a permissão da INTERNET no file AndroidManifest.xml .

       <uses-permission android:name="android.permission.INTERNET"/> 
      final String url = "some/url"; 

    ao invés de:

      final JSONObject jsonBody = "{\"type\":\"example\"}"; 

    você pode usair:

      JSONObject jsonBody = new JSONObject(); try { jsonBody.put("type", "my type"); } catch (JSONException e) { e.printStackTrace(); } new JsonObjectRequest(url, jsonBody, new Response.Listener<JSONObject>() { ... }); }  JSONObject jsonBody = new JSONObject(); try { jsonBody.put("type", "my type"); } catch (JSONException e) { e.printStackTrace(); } new JsonObjectRequest(url, jsonBody, new Response.Listener<JSONObject>() { ... }); 
     final Map<String,String> pairams = new HashMap<String,String>(); pairams.put("email", customer.getEmail()); pairams.put("password", customer.getPassword()); String url = Constants.BASE_URL+"login"; doWebRequestPost(url, pairams); public void doWebRequestPost(String url, final Map<String,String> json){ getmDialogListener().showDialog(); StringRequest post = new StringRequest(Request.Method.POST, url, new Response.Listener<String>() { @Oviewride public void onResponse(String response) { try { getmDialogListener().dismissDialog(); response.... } catch (Exception e) { e.printStackTrace(); } } }, new Response.ErrorListener() { @Oviewride public void onErrorResponse(VolleyError error) { Log.d(App.TAG,error.toString()); getmDialogListener().dismissDialog(); } }){ @Oviewride protected Map<String, String> getPairams() throws AuthFailureError { Map<String,String> map = json; return map; } }; App.getInstance().getRequestQueue().add(post); } } catch (Exception e) { final Map<String,String> pairams = new HashMap<String,String>(); pairams.put("email", customer.getEmail()); pairams.put("password", customer.getPassword()); String url = Constants.BASE_URL+"login"; doWebRequestPost(url, pairams); public void doWebRequestPost(String url, final Map<String,String> json){ getmDialogListener().showDialog(); StringRequest post = new StringRequest(Request.Method.POST, url, new Response.Listener<String>() { @Oviewride public void onResponse(String response) { try { getmDialogListener().dismissDialog(); response.... } catch (Exception e) { e.printStackTrace(); } } }, new Response.ErrorListener() { @Oviewride public void onErrorResponse(VolleyError error) { Log.d(App.TAG,error.toString()); getmDialogListener().dismissDialog(); } }){ @Oviewride protected Map<String, String> getPairams() throws AuthFailureError { Map<String,String> map = json; return map; } }; App.getInstance().getRequestQueue().add(post); } } final Map<String,String> pairams = new HashMap<String,String>(); pairams.put("email", customer.getEmail()); pairams.put("password", customer.getPassword()); String url = Constants.BASE_URL+"login"; doWebRequestPost(url, pairams); public void doWebRequestPost(String url, final Map<String,String> json){ getmDialogListener().showDialog(); StringRequest post = new StringRequest(Request.Method.POST, url, new Response.Listener<String>() { @Oviewride public void onResponse(String response) { try { getmDialogListener().dismissDialog(); response.... } catch (Exception e) { e.printStackTrace(); } } }, new Response.ErrorListener() { @Oviewride public void onErrorResponse(VolleyError error) { Log.d(App.TAG,error.toString()); getmDialogListener().dismissDialog(); } }){ @Oviewride protected Map<String, String> getPairams() throws AuthFailureError { Map<String,String> map = json; return map; } }; App.getInstance().getRequestQueue().add(post); } } final Map<String,String> pairams = new HashMap<String,String>(); pairams.put("email", customer.getEmail()); pairams.put("password", customer.getPassword()); String url = Constants.BASE_URL+"login"; doWebRequestPost(url, pairams); public void doWebRequestPost(String url, final Map<String,String> json){ getmDialogListener().showDialog(); StringRequest post = new StringRequest(Request.Method.POST, url, new Response.Listener<String>() { @Oviewride public void onResponse(String response) { try { getmDialogListener().dismissDialog(); response.... } catch (Exception e) { e.printStackTrace(); } } }, new Response.ErrorListener() { @Oviewride public void onErrorResponse(VolleyError error) { Log.d(App.TAG,error.toString()); getmDialogListener().dismissDialog(); } }){ @Oviewride protected Map<String, String> getPairams() throws AuthFailureError { Map<String,String> map = json; return map; } }; App.getInstance().getRequestQueue().add(post); } } final Map<String,String> pairams = new HashMap<String,String>(); pairams.put("email", customer.getEmail()); pairams.put("password", customer.getPassword()); String url = Constants.BASE_URL+"login"; doWebRequestPost(url, pairams); public void doWebRequestPost(String url, final Map<String,String> json){ getmDialogListener().showDialog(); StringRequest post = new StringRequest(Request.Method.POST, url, new Response.Listener<String>() { @Oviewride public void onResponse(String response) { try { getmDialogListener().dismissDialog(); response.... } catch (Exception e) { e.printStackTrace(); } } }, new Response.ErrorListener() { @Oviewride public void onErrorResponse(VolleyError error) { Log.d(App.TAG,error.toString()); getmDialogListener().dismissDialog(); } }){ @Oviewride protected Map<String, String> getPairams() throws AuthFailureError { Map<String,String> map = json; return map; } }; App.getInstance().getRequestQueue().add(post); } } final Map<String,String> pairams = new HashMap<String,String>(); pairams.put("email", customer.getEmail()); pairams.put("password", customer.getPassword()); String url = Constants.BASE_URL+"login"; doWebRequestPost(url, pairams); public void doWebRequestPost(String url, final Map<String,String> json){ getmDialogListener().showDialog(); StringRequest post = new StringRequest(Request.Method.POST, url, new Response.Listener<String>() { @Oviewride public void onResponse(String response) { try { getmDialogListener().dismissDialog(); response.... } catch (Exception e) { e.printStackTrace(); } } }, new Response.ErrorListener() { @Oviewride public void onErrorResponse(VolleyError error) { Log.d(App.TAG,error.toString()); getmDialogListener().dismissDialog(); } }){ @Oviewride protected Map<String, String> getPairams() throws AuthFailureError { Map<String,String> map = json; return map; } }; App.getInstance().getRequestQueue().add(post); } }; final Map<String,String> pairams = new HashMap<String,String>(); pairams.put("email", customer.getEmail()); pairams.put("password", customer.getPassword()); String url = Constants.BASE_URL+"login"; doWebRequestPost(url, pairams); public void doWebRequestPost(String url, final Map<String,String> json){ getmDialogListener().showDialog(); StringRequest post = new StringRequest(Request.Method.POST, url, new Response.Listener<String>() { @Oviewride public void onResponse(String response) { try { getmDialogListener().dismissDialog(); response.... } catch (Exception e) { e.printStackTrace(); } } }, new Response.ErrorListener() { @Oviewride public void onErrorResponse(VolleyError error) { Log.d(App.TAG,error.toString()); getmDialogListener().dismissDialog(); } }){ @Oviewride protected Map<String, String> getPairams() throws AuthFailureError { Map<String,String> map = json; return map; } }; App.getInstance().getRequestQueue().add(post); } 

    Você também pode enviair dados, substituindo o método JsonObjectRequest getBody() da class JsonObjectRequest . Como mostrado abaixo.

      @Oviewride public byte[] getBody() { JSONObject jsonObject = new JSONObject(); String body = null; try { jsonObject.put("username", "user123"); jsonObject.put("password", "Pass123"); body = jsonObject.toString(); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { return body.toString().getBytes("utf-8"); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } {  @Oviewride public byte[] getBody() { JSONObject jsonObject = new JSONObject(); String body = null; try { jsonObject.put("username", "user123"); jsonObject.put("password", "Pass123"); body = jsonObject.toString(); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { return body.toString().getBytes("utf-8"); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } {  @Oviewride public byte[] getBody() { JSONObject jsonObject = new JSONObject(); String body = null; try { jsonObject.put("username", "user123"); jsonObject.put("password", "Pass123"); body = jsonObject.toString(); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { return body.toString().getBytes("utf-8"); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } {  @Oviewride public byte[] getBody() { JSONObject jsonObject = new JSONObject(); String body = null; try { jsonObject.put("username", "user123"); jsonObject.put("password", "Pass123"); body = jsonObject.toString(); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { return body.toString().getBytes("utf-8"); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } // TODO Bloqueio de captura gerado automaticamente  @Oviewride public byte[] getBody() { JSONObject jsonObject = new JSONObject(); String body = null; try { jsonObject.put("username", "user123"); jsonObject.put("password", "Pass123"); body = jsonObject.toString(); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { return body.toString().getBytes("utf-8"); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } }  @Oviewride public byte[] getBody() { JSONObject jsonObject = new JSONObject(); String body = null; try { jsonObject.put("username", "user123"); jsonObject.put("password", "Pass123"); body = jsonObject.toString(); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { return body.toString().getBytes("utf-8"); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } {  @Oviewride public byte[] getBody() { JSONObject jsonObject = new JSONObject(); String body = null; try { jsonObject.put("username", "user123"); jsonObject.put("password", "Pass123"); body = jsonObject.toString(); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { return body.toString().getBytes("utf-8"); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } {  @Oviewride public byte[] getBody() { JSONObject jsonObject = new JSONObject(); String body = null; try { jsonObject.put("username", "user123"); jsonObject.put("password", "Pass123"); body = jsonObject.toString(); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { return body.toString().getBytes("utf-8"); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } // TODO Bloqueio de captura gerado automaticamente  @Oviewride public byte[] getBody() { JSONObject jsonObject = new JSONObject(); String body = null; try { jsonObject.put("username", "user123"); jsonObject.put("password", "Pass123"); body = jsonObject.toString(); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { return body.toString().getBytes("utf-8"); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } }  @Oviewride public byte[] getBody() { JSONObject jsonObject = new JSONObject(); String body = null; try { jsonObject.put("username", "user123"); jsonObject.put("password", "Pass123"); body = jsonObject.toString(); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { return body.toString().getBytes("utf-8"); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } return nulo;  @Oviewride public byte[] getBody() { JSONObject jsonObject = new JSONObject(); String body = null; try { jsonObject.put("username", "user123"); jsonObject.put("password", "Pass123"); body = jsonObject.toString(); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { return body.toString().getBytes("utf-8"); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.