Accessing screen size and density
In the Running your sketch in the Android Emulator recipe, you've learned that the Android OS sets the size of your sketch window. In this recipe, we'll take a look at how we can access the width, height, DPI, and density values of the screen. There are a lot of Android devices with different screen sizes and resolutions. These values can be used to make your app look good on all of these devices.
Getting ready
I've used the font Junction in this example, an open source font made by The League of Moveable Type. You can download the font from http://www.theleagueofmoveabletype.com/junction. Drag the font file Junction.otf
onto the Processing editor so you can use it in your sketch.
How to do it...
We'll start by importing the Android DisplayMetrics
class, and declare some String variables and one variable for the font we'll use to display these strings on the screen:
import android.util.DisplayMetrics; String density; String dpi; String w; String h; PFont...