Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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": "http://api.rottentomatoes.com/api/public/v1.0/movies/771205893.json"). 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:

{

"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",

}

}],

This is my 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 < movies.length(); i++) {
                    JSONObject movie = movies.getJSONObject(i);
                    movieTitles[i] = movie.getString("title");
                }

                try {
                    movieId = new String[movies.length()];
                    for (int i = 0; i < movies.length(); i++) {
                        JSONObject movie = movies.getJSONObject(i);
                        movieId[i] = movie.getString("id");

                    }

After i get the movieId i want to get only the movie id that the user has pressed so i use :

   public void onItemClick(AdapterView<?> arg0, View arg1,
                int position, long id) {

            Intent i = new Intent(getApplicationContext(),
                    AfterClickingMovieFromInternet.class);

            i.putExtra("movieName", movieTitles[position]);
            getMovieInfo( movieId[position]);

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!

share|improve this question
Have you tried to Toast or Log the e.toString();? Remember you are not able to Toast in the doInBackground you'll do it in onPostExcute – H-Development Jun 16 at 15:23
i try to sent the string given to anther activity but the string sent was null – user2252496 Jun 16 at 15:44

1 Answer

What is the problem with 2 consecutive connections? Did you check libraries?

I would recommend this one - https://github.com/kodart/Httpzoid Is uses GSON internally and provides API that works with objects. All JSON details are hidden.

Http http = HttpFactory.create(context);
http.get("http://example.com/users")
    .handler(new ResponseHandler<User[]>() {
        @Override
        public void success(User[] users, HttpResponse response) {
        }
    }).execute();
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.