Android MovieApp using Retrofit and MovieDB API to Show Movies on RecyclerView,GridView and Show YouTube Trailers

By | January 19, 2018

This tutorial we are learning how to create an android application that will be showing Latest movies, Favorites movies and Most Popular movies in a gridview using Movie DB APIs.
The App will enable users to stream these movies trailers from Youtube.

Users can change settings(using SharedPreferences) to enable the app display either favorites movie(which users have saved), Highest rated movies from movie DB API and or Most Popular movies.

When users click on specific movie displayed in the gridview they will be taken to details screen where they will see details about the movie and also there is add to favorites button, and full image of the movie and at the bottom will show all the trailers a movie has in youtube

The following are the end result of this app.

 

Firstly we need to get API key from the movie DB website. You can visit the site register an account and apply for API key.

This API key is used to access the content from their database.

We are going to load data using android Retrofit Library which renders JSON data to the android device, Glide for rendering images and caching.

Lets get started,Create a new project “MovieApp” using latest android studio IDE and add the following libraries in build.gradle(Module:app)

 

 

For security reasons, we will have our API key stored in gradle.properties(Project Properties) as shown below snippet

 

We will call the API key in build.gradle(Module:app) file which will look as follows

Having configured properly you can add the following for activity_main.xml files.

create content_main.xml file which will contain content of activity_main.xml

Under Java create a new package called adapter under it create “MoviesAdapter” class and have the following codes in this class.

 

Create another package called model and in it create Movie class which implements Parcelable interface which allows serialization of objects rather fast.The following are object/String parsed under the Movie class.

 

Create api package and under it create  Client  class and Service interface this are use to fetch API keys and api url.

 

To get full source codes which include Admob Adds both interstitial and banner Add download from the link below

@ $5

9 thoughts on “Android MovieApp using Retrofit and MovieDB API to Show Movies on RecyclerView,GridView and Show YouTube Trailers

Leave a Reply

Your email address will not be published. Required fields are marked *