Aaron Liew's Blog

Blog about Android Development

TroubleShoot of the Movie Search App

My initial attempt was to extract the JSON data from the movie database using API key. All the JSON data is displayed in LogCat instead of displaying the JSON data in the app. First of all, I have modified the coding in the AndroidManifest xml file that is from:




The purpose of the changing the name of the activity is to test the workability of the small part of the coding of Movie Search app using MainActivityDev JAVA script. In MainActivityDev.java, JSONReader.readJsonFromUrl command is used to get JSON Text format from the movie database URL. The GSON library is used to convert the JSON data to Java DataObject, then, display it in the LogCat window by using the command as shown below:


In Log.d, “test” is a tag which will be presented in the LogCat window along with the string “obj.getResults(). get(0).getId().toString()”. If there are any error or exception, ‘Log.e’ will be used to display the error message in the window. The code of MainActivityDev.Java is shown below.

public class MainActivityDev extends Activity {
public void onCreate(Bundle savedInstanceState) {

    final Gson gson= new Gson();

    new Thread(new Runnable() {
        public void run() {
            try {
                 String json = (String) JSONReader.readJsonFromUrl("https://api.themoviedb.org/3/search/movie?" +

                 Movie obj = gson.fromJson(json, Movie.class);

                 json = (String) JSONReader.readJsonFromUrl("https://api.themoviedb.org/3/movie/" 
                         + obj.getResults().get(0).getId().toString() + 

                 ImdbMovie imdbData = gson.fromJson(json, ImdbMovie.class);

            } catch (IOException e) {
                Log.e("test", e.getMessage());
            } catch (JSONException e) {
                Log.e("test", e.getMessage());