-3
// CODIGO ANTIGO QUE NAO ATUALIZA, MAS UTILIZA UTF-8.
Cache cache = AppController.getInstance().getRequestQueue().getCache();
if (cache.get(URL_FEED) != null) {
// fetch the data from cache
try {
String data = new String(cache.get(URL_FEED).data, "utf-8");
try {
parseJsonFeed(new JSONObject(data));
} catch (JSONException e) {
e.printStackTrace();
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
} else {
// making fresh volley request and getting json
JsonObjectRequest jsonReq = new JsonObjectRequest(Method.GET,
URL_FEED, null, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
VolleyLog.d(TAG, "Response: " + response.toString());
if (response != null) {
parseJsonFeed(response);
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
VolleyLog.d(TAG, "Error: " + error.getMessage());
}
});
// Adding request to volley request queue
AppController.getInstance().addToRequestQueue(jsonReq);
}
}
// CODIGO QUE ATUALIZA, MAS NAO UTILIZA UTF-8.
JsonObjectRequest jsonReq = new JsonObjectRequest ( Method . GET ,
URL_FEED , null , new Response . Listener < JSONObject >() {
Override
pública vazio onResponse ( JSONObject resposta ) {
VolleyLog . d ( TAG , "Resposta:" + resposta . toString ());
se ( resposta ! = NULL ) {
parseJsonFeed ( resposta );
}
}
}, nova resposta . ErrorListener ( ) {
Override
pública vazio onErrorResponse ( VolleyError erro ) {
VolleyLog . d ( TAG , "Erro:" + erro . getMessage ());
}
});
And what is the question? PS: What are these
pública
,vazio
,se
andnova resposta
?– Renan Gomes
My question is: this first code is where utf-8 is working but without updating my .json. The second code already updates, plus the phrases of my file. json get confused without utf-8. How do I get it to appear in the second code updating and appearing the accent phrases?
– Mauro Santos