O'Reilly logo

Cardboard VR Projects for Android by Matt Schoen, Jonathan Linowes

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Loading and displaying a photo image

So far, we've used images in the project's drawable resource folder. The next step is to read photo images from the phone and display one on our virtual screen.

Defining the image class

Let's make a placeholder Image class. Later on, we'll build the attributes and methods. Define it as follows:

public class Image { final static String TAG = "image"; String path; public Image(String path) { this.path = path; } public static boolean isValidImage(String path){ String extension = getExtension(path); if(extension == null) return false; switch (extension){ case "jpg": return true; case "jpeg": return true; case "png": return true; } return false; } static String getExtension(String path){ String[] split = path.split("\\."); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required