Podpora The Movie Database

I want to get genre id and genre name for specific movie so I am generating this type of query:

http://api.themoviedb.org/3/movie/321612?api_key=xxxxx

and I am getting all the response in my Model class Movie.java but I am getting genre ids and genre name of a specific movie null. I am creating MovieGenre.java class which looks like this:

public class MovieGenres
{
    @SerializedName("id")
    private int id;
    @SerializedName("genre_name")
    private String  genre_name;

    public MovieGenres(int id,String genre_name )
    {
        this.id = id;
        this.genre_name=genre_name;
    }


    public String getGenre_name()
    {
        return genre_name;
    }

    public void setGenre_name(String genre_name)
    {
        this.genre_name = genre_name;
    }

    public int getId()
    {

        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

And Now I am Creating a List variable in the Movie class and Setter and Getter for this variable and the class Movie looks like this:

Movie.java
public class Movie
{
 @SerializedName("movie_genres")
    private List<MovieGenres>movie_genres = new ArrayList<MovieGenres>() ;

Movie(List<MovieGenres> movie_genres)
{
this.movie_genre=movie_genre;
}
public void setMovie_genres(List<MovieGenres> movie_genres)
   {
        this.movie_genres = movie_genres;
    }

 public List<MovieGenres> getMovie_genres()
    {
        return movie_genres;
    }
}

Now the result I am getting is null and I do not want to cache the genres list which is suggested by the API team. So what should I do

7 odpovědí (na stránce 1 z 1)

Jump to last post

The "get details" method returns an array with the name already provided, so I am not 100% sure I understand the issue.

http://api.themoviedb.org/3/movie/321612?api_key=xxxxx
{
  ...
  "genres": [
    {
      "id": 14,
      "name": "Fantasy"
    },
    {
      "id": 10749,
      "name": "Romance"
    }
  ],
  ...
}

Is that not the data you are trying to use?

Yes this is the data I am trying to retrieve but not not able to retrieve I am getting null

It looks like you're looking a field with the name genre_name and not name. But I don't know Java, so this is a guess.

I have used name also there but no use I still got null response .

Hi @bit_coder

I'm not sure how else I can help, you can see the data in the response. That's about all I can say. Maybe take a look at some of the Java libraries and see how they're grabbing the data.

Ok I will try to solve it btw I am using retrofit library.

i wonder if he founds the solution because i came here after searching the same problem :D but soon i realized that my variable of Genre class is genre not name. changing it to name solve the problem because you need to have same name of the variable as key.

Nemůžete nalézt film nebo seriál? Přihlaste se pro jeho vytvoření.

Globální

s zaměřit panel hledání
p otevřít nabídku profilu
esc zavřít otevřené okno
? otevřít okno klávesových zkratek

Na stránkách médií

b zpět (nebo na nadřazený záznam, pokud to jde)
e na stránku úprav

Na stránkách sezón

(šipka vpravo) na další sezónu
(šipka vlevo) na předchozí sezónu

Na stránkách epizod

(šipka vpravo) na další epizodu
(šipka vlevo) na předchozí epizodu

Na všech stránkách obrázků

a otevřít okno přidání obrázku

Na všech stránkách úprav

t otevřít výběr překladu
ctrl+ s odeslat formulář

Na stránkách diskusí

n vytvořit novou diskusi
w přepnout stav zhlédnutí
p přepnout veřejný a soukromý
c přepnout zavřít a otevřít
a otevřít aktivitu
r odpovědět na diskusi
l na poslední odpověď
ctrl+ enter odeslat zprávu
(šipka vpravo) další stránka
(šipka vlevo) předchozí stránka

Nastavení

Want to rate or add this item to a list?

Přihlásit se