The YouTube Activity allows you to take video content from YouTube and display it in your Android application. For additional information on getting your YouTube IDs please see the Getting YouTube IDs and Creating a YouTube API Key knowledge base articles.
Error Codes: If you encounter any error messages/codes in your app while testing, please see the YouTube Activity Error Codes section of this article for a description of the error.
Note: This activity uses the YouTube Data API v3. All applications must register to obtain the proper authorization credentials. See the "YouTube API Key" setting for further details.
To add a YouTube activity to your project: start editing your project and go to the Activities tab. Under 'Your App Activities' click the + Add an Activity button and select YouTube from the list.
Now let's take a look at the YouTube Activity settings. For the purpose of this article we will use the Google I/O YouTube video Playlist.
The name that you want to give to your activity. This will appear on the dashboard, toolbar, and navigation drawer. This can be whatever you want but should probably describe the items that you will be displaying. For our example we'll use "Android I/O"
A few words describing this activity. This subtitle text may be displayed on the dashboard if the dashboard's item style supports it.
A longer paragraph describing this activity. This description text may be displayed on the dashboard if the dashboard's item style supports it.
This is a relative index that controls the order of the activities in your application. The position will effect where your activity is displayed on the dashboard and navigation drawer. For more information on this setting please read: How to change the order of the icons on the dashboard
Whether or not this activity will be included in the app. This may be useful if you're creating different versions of your app that you want to contain different content.
When selected, this activity won't show on the dashboard or the navigation drawer. You can still access this activity from an HTML-based activity using it's Activity URL. For more information, refer to the topic Linking to Another Activity.
The Theme setting allows you to inherit theme settings from the global theme, parent theme, or override the theme settings for the activity. See the Activity Theme topic for descriptions of these settings.
The Images section allows you to provide the images to show on the activity and those that will be used to represent it on it's parent dashboard and navigation drawer. See the Activity Images topic for descriptions of these settings.
The Toolbar setting allows you to inherit the toolbar settings from the global toolbar, parent toolbar, or override the toolbar settings for the activity. See the Activity Toolbar topic for descriptions of these settings.
This setting controls which value will be used to generate your list of videos. Choose from Username, Playlist ID, Search phrase, or Single video.
Show videos belonging to a specific user using their YouTube username, such as AndromoAppMaker.
Show videos belonging to a playlist using a YouTube playlist ID, such as Andromo's Quick Tips playlist, PLQIkRevU6k8XJUjoQ2qmjyl6Vovwa6npR.
Show videos matching a YouTube search phrase or query, such as porsche+red.
Show a single video using it's full URL provided by YouTube such as: http://www.youtube.com/watch?v=HguXVfPgpBY. This option will open the video directly, instead of showing a list.
Note: This setting isn't required for the 'Single video URL' option.
In order to submit API requests to YouTube's Data API v3, you must register your application to obtain the proper authorization credentials. To register your application, go to the Google Developer Console to create your project and your YouTube API Key. For more information, see the article Creating a YouTube API Key.
The item style you want to use to show the index of YouTube videos. Choose from styles such as cards, grids, and lists including which content you want to show.
The unique reference URL for this activity that can be used for linking to it. For an example of it's usage, refer to the topic Linking to Another Activity.
If an error is encountered while requesting the data from YouTube's API, the app will show a message containing an error code, such as "YouTube Data Error (53)". Below are descriptions of Andromo's error codes that you may encounter. You can use these to help diagnose any incorrect values you've entered.
- 50 - An error occurred when trying to initialize the YouTube Data API.
- 53 - The YouTube API Key you've entered is invalid.
- 54 - The Playlist ID you've entered is invalid or not found.
- 55 - The Username you've entered is invalid or not found.
- 56 - No 'uploads' were returned for the username you've specified.
- 57 - You're not authorized to retrieve the specified playlist.
- 58 - You have exceeded your YouTube quota.
- 59 - Access Not Configured. Please use Google Developers Console to activate the API for your project.
- 99 - An unknown error occurred while retrieving the YouTube data.
The YouTube Activity contains one activity, a list of items generated by the YouTube request. When you initially visit this activity it will be blank, and your Andromo app will query YouTube using their API and populate it with items. Each item will contain a title, date the item was published, a short description, and a video thumbnail (the specific elements shown will depend on what Item Style you select):
You can scroll through the list and select an item to view. When you click on an item you will be brought to YouTube app where you can view the video. If the YouTube app is not installed then the video will be opened in the user's web browser.