Quantcast
Channel: Android Mode - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 941

Run certain code only when in Android Mode

$
0
0

How do people run code that is only relevant when running on a phone?

For example I want my sketch look the same in Java and in Android mode. For this I have to use a strokeWeight that is proportional to displayDensity. Problem is the this variable is only available in Android mode. Similarly I only want to call size(width, height) in Java mode.

I can check for Android ...

if (System.getProperty("java.vendor") == "The Android Project") { strokeWeight(3*displayDensity) }

... but this will not compile because Java. In Javascript/Python this would just work because lazy evaluation and in C++ this could be done with #defines.

How do you do that in Processing/Java. Anybody knows a trick to make it work? Reflection module (looks crazy verbose)?

Let me know, Best,


Viewing all articles
Browse latest Browse all 941

Trending Articles