Я могу получить информацию JSON из URL-адреса в течение нескольких минут, однако в конечном итоге это даст мне «Неожиданный код ответа 429». Ссылка из Steam, мне интересно, если это проблема с Volley или Steam? Вот моя текущая реализация, поскольку это возможно. Я что-то пропустил из своего кода.Неожиданный код ответа 429 при использовании Volley в Android?
RequestQueue queue = Volley.newRequestQueue(this);
// Request a string response from the provided URL.
JsonObjectRequest stringRequest = new JsonObjectRequest(Request.Method.GET, retrievalURL, null,
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
try {
int indexOfWear = listOfWears.indexOf(wear);
Map<String, String> itemInList = listWearsAndPrices.get(indexOfWear);
if (response.getBoolean("success")) {
itemInList.put("Price", response.getString("lowest_price"));
} else {
// If price is not possible
itemInList.put("Price", "Item Unavailable");
Log.e("tag", "Item unavailable unreached");
}
// Update view
adapter.notifyDataSetChanged();
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
/**
* TODO
* CHECK FOR INTERNET CONNECTION
*/
int indexOfWear = listOfWears.indexOf(wear);
Map<String, String> itemInList = listWearsAndPrices.get(indexOfWear);
itemInList.put("Price", "Item Unavailable");
adapter.notifyDataSetChanged();
}
});
// Add the request to the RequestQueue.
queue.add(stringRequest);
Вы проверили подключение к Интернету, прежде чем воспользоваться услугой? –