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("\\."); ...

Get Cardboard VR Projects for Android now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.