teaching machines

Last.fm Artist Finder – kendziba hw3

November 7, 2011 by . Filed under cs491 mobile, fall 2011, postmortems.

For this homework assignment I decided to hook into the API of one of my favorite online music sites; last.fm!

Last.fm is an online community focused around tracking the music users listen to and providing recommendations based on that data. Last.fm also does a very good job at providing useful data about different musicians like up-to-date bios, pictures, concert listings, etc.

My application allows mobile users to search the last.fm database for an artist, and to select that artist to view more information about them. Last.fm’s api does allow JSON, so it made short work of getting the data… but I wasn’t quite ready for the complexity that JSON allows.

I used the Artist.search and Artist.getInfo API methods for my two separate queries (searching, getting additional info about the searched artist). Both of these queries return strings that include JSON objects inside of JSON objects inside of JSON arrays inside of another JSON object (phew!). Parsing out the results was quite difficult to get a hang of, and would’ve been more than impossible without this handy little tool I found. This made viewing the JSON strings a breeze.

I also ran into troubles trying to make my Artist class Parcelable… besides making it implement the Parcelable interface I was getting strange errors trying to cast an array of Parcelables into an array of Artists, and I ended up just needing to keep it as an array of Parcelables until I used the elements inside, in which case I did an on-the-fly cast which seemed to work. Using the Service pattern that was discussed in class was very handy and extremely expandable. I ended up creating two different flags sent to the Service class that handled either the artist search or the artist info queries.