Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You didn't post your implementation of the <code>TweetRequest</code> class, but if I had to make an educated guess, I'm guessing that it inherits form the <code>JsonRequest</code> class which automatically casts the string response into a JSON <strong>object</strong>.</p> <p>The thing is, the response you're receiving is a JSON <strong>array</strong>. </p> <p>So if my guess was correct, your <code>TweetRequest</code> should inherit from <code>JsonArrayRequest</code> instead.</p> <p>Did I read the situation correctly?</p> <h2>EDIT:</h2> <p>OK, how about trying this:</p> <p>Instead of converting a <code>JsonObject</code> to a <code>JsonArray</code> make your request an array request:</p> <pre><code>public class TweetsRequest extends JsonArrayRequest { // basically the same implementation you have now } </code></pre> <p>You'll need to update your listeners because the response will now be a <code>JsonArray</code>.</p> <h2>EDIT 2:</h2> <p>It seems you have left overs from the <code>JSONObject</code> request and listeners. This should be your <code>TweetJsonListener</code> - notice I've only use the correct method override and pasted your implementation into it. I did not validate your logic</p> <pre><code>private class TweetJsonListener implements Listener&lt;JSONArray&gt; { @Override public void onResponse(JSONArray response) { JSONObject jsonObject = null; JSONArray tweets = response.optJSONArray("statuses"); int count = tweets != null ? tweets.length() : 0; for (int i = 0; i &lt; count; i++) { jsonObject = tweets.optJSONObject(i); if (jsonObject != null) { tweetAdapter.add(jsonObject); } activity.setProgressBarIndeterminateVisibility(false); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload