Note that there are some explanatory texts on larger screens.

plurals
  1. POandroid JSON parsing How to make two http Connection one after the other
    primarykey
    data
    text
    <p>Im using Rotten Tomatoes api and for some reason if i want to get more information about a movie like the movie director or the studio I need another http page. this is the url that im getting movie-info. from this JSON i get the id ( "self": "<a href="http://api.rottentomatoes.com/api/public/v1.0/movies/771205893.json" rel="nofollow">http://api.rottentomatoes.com/api/public/v1.0/movies/771205893.json</a>"). and i want to use that id- i want to make another http connection to that specific url and get more information about each movie. this is the movie-info JSON: </p> <pre><code>{ "total": 591, "movies": [{ "title": "Jack and Jill", "year": 2011, "runtime": "", "release_dates": {"theater": "2011-11-11"}, "ratings": { "critics_score": -1, "audience_score": 90 }, "synopsis": "", "posters": { }, "abridged_cast": [ { "name": "Al Pacino", "characters": [] }, { "name": "Adam Sandler", "characters": [] }, { "name": "Katie Holmes", "characters": [] } ], "links": { "self": "http://api.rottentomatoes.com/api/public/v1.0/movies/771205893.json", } }], </code></pre> <p>This is my code: </p> <pre><code> if (response != null) { try { // convert the String response to a JSON object, // because JSON is the response format Rotten Tomatoes uses JSONObject jsonResponse = new JSONObject(response); // fetch the array of movies in the response JSONArray movies = jsonResponse.getJSONArray("movies"); // add each movie's title to an array movieTitles = new String[movies.length()]; for (int i = 0; i &lt; movies.length(); i++) { JSONObject movie = movies.getJSONObject(i); movieTitles[i] = movie.getString("title"); } try { movieId = new String[movies.length()]; for (int i = 0; i &lt; movies.length(); i++) { JSONObject movie = movies.getJSONObject(i); movieId[i] = movie.getString("id"); } </code></pre> <p>After i get the movieId i want to get only the movie id that the user has pressed so i use :</p> <pre><code> public void onItemClick(AdapterView&lt;?&gt; arg0, View arg1, int position, long id) { Intent i = new Intent(getApplicationContext(), AfterClickingMovieFromInternet.class); i.putExtra("movieName", movieTitles[position]); getMovieInfo( movieId[position]); </code></pre> <p>and in the getMovieInfo( movieId[position]) im trying to make a second connection to the api but for some reason it wont execute..... if anyone got any idea ill be happy to know! </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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.
    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