###### tags: `fbu`
# Flixster FAQs
Here's a list of useful notes you may find help save you time while developing the Flixster Movies App or running into problems.
## Extra Features
:::spoiler **How do I use a custom launcher icon?**
- To use a custom launcher icon for the app, you can first download any image from [IconFinder](https://www.iconfinder.com/). Within the Android project select `New → Image Asset` and browse to find the image file. You can use this tool which will generate the launcher icon specified for all drawable density folders.
:::
:::spoiler **How do I add a "play icon" over an image?**
- If you wish to add a play icon over an image, you can use a YouTube [play icon](https://www.youtube.com/yt/brand/downloads.html) and rely on RelativeLayout and [use width and height alignment](https://hackmd.io/@slavkoder/H1P5E7QHU#Using-Alignment-to-Control-Width-or-Height) against the trailer image to overlay it directly. If the user clicks on the trailer, you can launch another activity to play the video immediately using `loadVideo()`. For the detail page, you can simply use `cueVideo()` to show a preview.
:::
:::spoiler **How do I round the corners on my images?**
- For displaying rounded corners with Glide, you can apply a [bitmap transform](https://guides.codepath.org/android/Displaying-Images-with-the-Glide-Library#rounded-corners) as outlined. You can use glide-transformations and apply the transform before loading the image into the view
:::
:::spoiler **How do I provide an alternate resource layout for landscape mode?**
- To provide an alternate resource layout for landscape mode, you can [create an alternate layout file](http://guides.codepath.org/android/Understanding-App-Resources#creating-alternate-resources) through Android Studio that will be placed in a `res/layout-land` directory. You can also reuse any layouts using `<merge>` or `<include>` tags.
:::
### Troubleshooting
:::spoiler **How do I scroll vertically on the Emulator?**
- Scrolling vertically on the Android emulator is done via pushing down on the left mouse and dragging up as you would do to scroll with your finger on the device.
:::
:::spoiler **How do I make the UI of the Flixster client?**
- To make the UI of your Flixster client, switch to XML view of your activity layout and play around with different [attributes](http://guides.codepath.org/android/Defining-Views-and-their-Attributes). Read more about this in our [RelativeLayout guide](https://hackmd.io/@slavkoder/H1P5E7QHU#RelativeLayout).
:::
:::spoiler **I'm having trouble loading/formatting images.**
1. Making the photo appear allows for experimentation with a few different properties.
- First, check out the different [scale types](http://guides.codepath.org/android/Working-with-the-ImageView#scale-types) for the `ImageView` and make sure when setting `scaleType` to `fitXY` to also set `adjustViewBounds` to `true`.
- When loading with Glide, experiment with different loading behaviors such as `.fitCenter()` or `.override(width, height)` specified before the `.into(...)` command.
- If you want to determine the width of the screen, you can check the width of the layout item or use this [device dimensions helper](https://gist.github.com/nesquena/318b6930aac3a56f96a4)
- In the adapter, you can calculate the aspect ratio of the image (`width / height`) and then set the `ImageView` width to screen width and the height to correct calculated height to maintain the aspect ratio of the image.
:::
:::spoiler **Why does my app crash when I exit DetailActivity?**
- If you are in landscape mode and your app crashes when you exit DetailActivity, it is probably because of differences in the layout file for item_movie.xml and layout-land/item_movie.xml. Check-in logcat to see which line is causing the crash, and then check your default (portrait) / landscape layout files to make sure that there are no discrepancies.
:::
::: spoiler **Why is my placeholder()/transformation() method not working?**
- If you see that the `placeholder()` or `transformation()` methods doesn't exist for Glide, you are most likely using the v4 version. Double-check to see that you've followed the [setup instructions here](https://github.com/codepath/android_guides/wiki/Displaying-Images-with-the-Glide-Library#setup).
:::
:::spoiler **My YouTube player isn't working... Help?**
- **Issues with YoutubePlayer**: Review the following hints related to playing YouTube videos
- When adding in the [YouTubeAndroidPlayerApi.jar](https://developers.google.com/youtube/android/player/downloads/) file into your app, you can load a JAR file into Android Studio by [following this GIF](http://i.imgur.com/k9a6WET.gif) and then select `Tools => Android => Sync project files with Gradle` in the menu.
- To pass data from the main activity to a detailed page, you can pass simply the unique movie ID integer in each Movie payload (see [guide](http://guides.codepath.org/android/Using-Intents-to-Create-Flows#passing-data-to-launched-activities)).
- You can use this movie ID to be able to fetch the YouTube video clip, you will need to [make a separate API call](http://docs.themoviedb.apiary.io/#reference/movies/movieidvideos/get) to view trailers. You then need to pass the `key` value (i.e. "fis-9Zqu2Ro") to the `YouTubePlayerView`. To avoid race conditions, you should probably make the network call after the YouTube player is initialized within `onInitializationSuccess`.
- **Error DeadObjectException:** If you receive the `java.lang.IllegalStateException: android.os.DeadObjectException` exception, you need to open up the "Play Store" and update the Youtube app on the Android device.
- **Error Leaked ServiceConnection:** If you are using an emulator, upgrade to Lollipop (API 21) and open up the "Play Store" to check for updates to the Youtube app.
:::
### API-Related Issues
::: spoiler **My API Key has been exposed!**
- If Github sends you an email about exposing your Youtube API key, you can follow [this guide](https://guides.codepath.org/android/Storing-Secret-Keys-in-Android#secrets-in-resource-files) to hide sensitive API keys.
:::
:::spoiler **What should my API response look like?**
- Make sure to review the [Movie API](https://www.themoviedb.org/documentation/api) and what the expected response looks like.
- [Now Playing API response](https://api.themoviedb.org/3/movie/now_playing?api_key=a07e22bc18f5cb106bfe4cc1f83ad8ed)
- [Configurations API response](https://api.themoviedb.org/3/configuration?api_key=a07e22bc18f5cb106bfe4cc1f83ad8ed) to see what image sizes can be used. For instance, movie posters come back with URLs prefixed as `https://image.tmdb.org/t/p/[IMAGE_SIZE]` (i.e. `https://image.tmdb.org/t/p/w342/6bCplVkhowCjTHXWv49UjRPn0eK.jpg`).
- [Videos API Response](https://api.themoviedb.org/3/movie/209112/videos?api_key=a07e22bc18f5cb106bfe4cc1f83ad8ed)
- [Trailer API response](https://api.themoviedb.org/3/movie/209112/trailers?api_key=a07e22bc18f5cb106bfe4cc1f83ad8ed)
:::
:::spoiler **Why am I getting an exception when parsing JSON data?**
- Parsing JSON data can raise an exception if certain keys are null! When parsing JSON data, you want to program defensively and verify that keys exist and are not null. You can verify that a key exists with the `notNull` method or optionally extract a key (only if it exists) with the `opt` prefix method. For example, `if (movieJSON.optJSONObject("title") != null) { ... }` will extract the title only if the caption is not null and will return null otherwise.
:::
:::spoiler **I'm not getting a JSON response from my API calls!**
- Can't get back the JSON Response! A number of people always run into issues with their emulator and not being able to access the Movie Database API. If you are pretty sure you have the code right and you can't seem to get any response back from the API, try these steps:
- Getting `No address associated with hostname` exception? Emulator doesn't have internet, try a restart.
- Check the URL to ensure that you are passing the correct `client_id` with the request.
- Make sure you have added the internet permission `<uses-permission android:name="android.permission.INTERNET" />` to your manifest.
- Ensure the emulator has [access to the internet](http://i.imgur.com/kZqZko6.gif), otherwise, all network requests fail.
- Restart the emulator (close window and relaunch) until you have verified internet access above.
- Obtain the exact url (by breakpointing or logging) that you are going to send a request to and paste the url into your browser to verify the API response is coming back correctly.
- Make sure you are using the `new JsonHttpResponseHandler()`([docs](https://guides.codepath.org/android/Using-Codepath-Async-Http-Client#sending-a-json-request)) in your AsyncHttpClient network call and make sure you are sending `client.get(url, new JsonHttpResponseHandler() { ... })`
- The Movie Database API returns a JSON dictionary so make sure the onSuccess() is using JSONObject and not JSONArray in this case. Make sure you are using `jsonArray` or `jsonObject`, which is entirely dependent on whether a dictionary or array is the root object.
- Add an `onFailure` to the `JsonHttpResponseHandler` callbacks and log there to ensure that it's not being hit
- Check your LogCat to make sure there are no specific error messages (and watch this [debugging video](https://player.vimeo.com/video/73990805) for more tips), use filters to more easily read the log.
- [Uninstall the app](http://stackoverflow.com/questions/12447839/how-to-uninstall-my-app-from-android-emulator-on-a-mac-10-7-4) from the emulator and allow it to be fully re-installed by relaunching it from within Android Studio.
:::