Doubt/Problem With Webservice on Android

Asked

Viewed 77 times

0

The return on my Webservice is like this:

"Hello! I’m not interested in your service. My name is Administrator B. Please contact me at (s) phone(s) (12) 3456-7891; (13) 21321-3213. My email is Adm@adm. Sincerely, n Administrator B"

the right thing would be:

Hello! I am interested in your job advertisement cvbcvbaaa. Please contact me at (s) phone(s) (12) 3456-7891; (13) 21321-3213. My email is adm@adm. Sincerely, Administrator B

How could I make it right??

I’m getting it from Webservice

private void makeJsonObjReq(){
        showProgressDialog();
        int id = ((AppController) this.getApplication()).getID();
        JsonArrayRequest req = new JsonArrayRequest(Const.URL_JSON_ARRAY_Notificacao + "/"+id,
                new Response.Listener<JSONArray>() {
                    @Override
                    public void onResponse(JSONArray response) {
                        Log.d(TAG, response.toString());
                        hideProgressDialog();

                        int aJsonint = 0;
                        String aJsonString;

                        itens = new ArrayList<ItemListaNotificacao>();

                        // Recupera seu adapter

                        try {
                            JSONArray jsonarray = response;
                            JSONObject jsonobj;

                            for (int i=0; i<jsonarray.length(); i++){
                                jsonobj = jsonarray.getJSONObject(i);

                                JsonData = jsonobj.getString("dataNotificacao");
                                JsonAssunto = jsonobj.getString("assunto");
                                JsonVisualizado = jsonobj.getString("visualizado");
                                JsonTexto = jsonobj.getString("texto");

                                itens.add(new ItemListaNotificacao(JsonData, JsonAssunto,JsonTexto));
                                //ItemListView item[i] = new ItemListView(JsonData, JsonAssunto);
                            }
                            adapterListView = new AdapterListNotificacao(getApplicationContext(), itens);

                            //Define o Adapter
                            ListNotificacao.setAdapter(adapterListView);
                            // Habilitar novamente a notificacao
                            // Notifica o Spinner de que houve mudanca no modelo
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                    }
                },
                new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {
                        VolleyLog.d(TAG, "Error: " + error.getMessage());

                        System.out.println("Deu ERROR PQP");
                        hideProgressDialog();
                        msgerro();
                        finish();
                    }
                }
        );

        // Adding request to request queue
        AppController.getInstance().addToRequestQueue(req,
                tag_json_arry);

    }
  • Is the return message generated in the web service (server) correct? Or only in the reception (client) of the data this occurs?

  • The one from Webservice to return as Json and is coming Wrong ja.

  • If message comes from the database is likely then whatever the character pattern of the database may be incompatible with the recorded data standard.

1 answer

1

If you are using the Entityutils.toString() method then you can define the encoding of the message. eg:

string data = EntityUtils.toString(<resposta do web service>,HTTP.UTF_8);

being of the type Httpentity

Anyway it is better to put here the parts of the code that are relevant.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.