The Easy Way: Implicit Intents

You will browse to this URL first by using your old friend the implicit intent. This intent will start up the browser with your photo URL.

The first step here is to make your app listen to presses on GridView items. This is another place where your code will look slightly different from your code in Chapter 9, since there is no matching GridFragment. Instead of overriding the onListItemClick(…) method in your fragment, you will hook it up more like a button click listener by calling the setOnItemClickListener(…) method on your GridView.

After doing that, it is a simple matter of creating and firing an implicit intent. Add the following code to PhotoGalleryFragment:

Listing 31.3  Web browsing with implicit intents ...

Get Android Programming: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.