Why It’s Time to Start Developing Apps for Google TV
The source code for this article can be downloaded here.
Google TV—Really?
Yes, really. It seems like we’ve been waiting for Smart TVs or Interactive TVs for quite a long time. Streaming video and movies on demand— for many years only a concept—has now become reality. Smart TVs with web browsing and apps is the next step, and Google TV is there.
With the release of the Android Honeycomb version for Google TV and, more importantly, the creation of an app market, Google has created a great ecosystem for television development. The earliest version of Google TV did not provide a way for developers to create and publish apps. That changed with the addition of the Google Play market.
Many new Google TVs and devices were released this year at CES. Manufacturers supporting Google TV include Sony, LG, Vizio, Asus, Hisense, and more. LG has seven Google TVs in its product lineup. Rather than develop their own proprietary systems, TV manufacturers can rely on Google and the Android operating system to provide smart TVs to consumers.
Google TV devices that attach to TVs are great to use and an inexpensive way to begin developing on GTV. These are known as "Buddy Systems." For example, the VIZIO Co-Star With Google TV is a $99 Google TV device.
Why Google TV Is Important
Common Platform
Google has used the Android operating system as a common platform across phone manufacturers. Google TV plays the same role for TV manufacturers. There is no common cross-manufacturer platform for TV development. Google TV fills that void.
Google TV provides a new app market.
The iPhone showed that an app marketplace was a key success factor for a new device. The iPad showed that a new form factor with a different size and shape makes a difference for both development of apps and how consumers use them.
Google TV includes both a new market for apps and a new experience for enjoying apps. This is a new opportunity for developers. It is a great time to jump into smart TV development on a Google TV.
Additionally, there really is something new with Google TV: Second-screen apps, in which a phone or a tablet interacts with a TV, provide exciting new opportunities for developers and app designers. Second-screen apps are covered in detail from a conceptual and development perspective in my book, which also covers the Anymote Library and how to use it with second-screen apps. Your phone and tablet apps will discover, connect to, and control Google TVs.
Creating a Second-Screen App
As an introduction to second-screen programming, I'll create a demo app that gets recent public photos from the Flickr stream. The app will display the 12 most recent photos on an Android phone or tablet. When the user selects an image, it will be displayed in large size on the TV.
Second-screen apps for Google TV use the Anymote protocol. Android apps will use the Anymote Library. Apps and TVs must discover and pair with each other. Those actions are handled by the Anymote Library.
Initially, the app displays the list of available devices.
When the device is selected, the TV shows a code for Pairing.
The app shows a screen for entering the info from the TV
When the user enters the proper credentials, the App is connected to the TV.
The app uses an Android XML layout file for the user interface. A GridView is used to display the images.
To keep things simple, the app consists of just two Java files. RecentPhotoActivity.java is the Android Activity class where all the action happens. FlickrPhoto.java contains data regarding a Flickr photo and methods to parse the JSON data that Flickr returns when we request a list of photos.
RecentPhotoActivity.java retrieves the 12 most recent public photos from Flickr. That is done in the background using an AsyncTask. The actual photos are retrieved and shown in the GridView.
When the user selects an image, the image is shown on the TV.
Because Flickr gives us a full URL for the image, we can let the Google TV system and Anymote protocol do most of the work. The Anymote protocol supports the concept of "Flinging" an Intent to the TV. We create an Intent using ACTION_VIEW and pass it a Uri with the data for the image. We are requesting apps that handle viewing URLs to fulfill this request. On the TV, the Chrome browser knows how to handle this Intent and displays the image.
The Flickr URL will be something like: http://farm9.staticflickr.com/8363/8439125544_1082cc4919_c.jpg
In the app, the variable selectedPhoto will contain that String. We turn the String into a URI, create an Intent, and send that Intent to the TV using the anyMoteSend.sendUrl method. That is done in these 2 lines.
final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(selectedPhoto)); anymoteSender.sendUrl (intent.toUri(Intent.URI_INTENT_SCHEME));
To try this yourself:
- Get an API_KEY from Flickr. http://www.flickr.com/services/apps/create/apply
- Set up an Android Development Environment. See http://developer.android.com/tools/index.html
- Download the Android project from this article as a zip file
- Import the project into your Android environment
- Replace the API_KEY in RecentPhotoActivity.java with your Flickr Api key
- Run the app
Conclusion
Google TVs and devices that run Google TV are widely available from major manufacturers, and Google TV buddy systems like the Vizio CoStar are priced around $100. The availability of these devices makes it is an ideal time to begin developing Google TV apps. Seeing an app that you develop on a big screen really is different from seeing an app on a computer or mobile phone. It is a great feeling. The ability to create second-screen apps is a new concept in user interface design. Google TV is a platform that supports creating these apps right now. I am sure that there is room for innovation and truly new ideas for creating second screen apps—so start developing!