Book Image

Mastering Android Game Development

By : Raul Portales
Book Image

Mastering Android Game Development

By: Raul Portales

Overview of this book

Table of Contents (18 chapters)
Mastering Android Game Development
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
API Levels for Android Versions
Index

Showing controller instructions


One of the special requirements for an app to be approved for Android TV is to provide a dialog indicating how the controller is mapped. For this Google provides us with a template that we can use and it is available online: (http://developer.android.com/training/tv/games/index.html).

Template for controller mapping

We already have a dialog that is displayed when a controller is connected, but we never updated it from being just an AlertDialog. It is time we made it a custom dialog.

The logic for phones was to show the dialog only the first time the main menu was loaded and a controller was connected. For Android TV, we want a different behavior: we want to show the dialog every time the game is opened.

To do this, we are going to overwrite the method showControllerHelp on MainMenuFragment to use a custom dialog with the template image modified to include the controls of our game.

As for other custom dialogs we have already made, we have to create a layout and...