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 is to make your app listen to presses on an item in the RecyclerView. Update PhotoGalleryFragment’s PhotoHolder to implement a click listener that will fire an implicit intent.

Listing 28.3  Firing implicit intent when item is pressed (PhotoGalleryFragment.java)

p​u​b​l​i​c​ ​c​l​a​s​s​ ​P​h​o​t​o​G​a​l​l​e​r​y​F​r​a​g​m​e​n​t​ ​e​x​t​e​n​d​s​ ​V​i​s​i​b​l​e​F​r​a​g​m​e​n​t​ ​{​
 ​ ​ ​ ​.​.​.​

 ​ ​ ​ ​p​r​i​v​a​t​e​ ​c​l​a​s​s​ ​P​h​o​t​o​H​o​l​d​e​r​ ​e​x​t​e​n​d​s​ ​R​e​c​y​c​l​e​r​V​i​e​w​.​V​i​e​w​H​o​l​d​e​r​
 ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​i​m​p​l​e​m​e​n​t​s​ ...

Get Android Programming: The Big Nerd Ranch Guide, 2nd Edition 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.