Search code examples
javaandroiditunes

itunes-search API Android


Due to unexpected circumstances I find myself coding an app for Android in Java(my experience is 0 with Android or Java), I´ve been doing so far very good, but now I´m stuck with something. I´m trying to Parse the iTunes Search API, and I´ve downloaded a library for doing so:

https://github.com/mdewilde/itunes-search

But I can´t manage to get the single parameters after making the Search(), this is my code:

Response response = new Search("La+vereda+de+la+puerta+de+atras").execute();
response.setResults(response.getResults());
Result result = new Result();
System.out.println(result.getArtistName().toString()); // Returns nil

Thank you very much in advanced


Solution

  • This would be the correct way of doing that:

    Response response = new Search("La+vereda+de+la+puerta+de+atras").execute();
    List<Result> results = response.getResults();
    
    if (results != null && results.size() > 0) {
        for(Result result : results) {
            System.out.println(result.getArtistName().toString());
        }
    } else {
        System.out.println("No results found :(");
    }