Processing With Android

Using libraries is an essential part of programming. Java, being the most used programming language in the world, has a lot of frameworks and people use them every day. Just take a look at JavaScript. A very small amount of JavaScript developer use “vanilla” JavaScript. They all use some sort of a framework, like React, Angular, Node.js and so forth. Frameworks are useful because they solve problems so that you don’t have to. You don’t have to reinvent the wheel. If you’ve encountered a problem, there is a big chance that someone else already solved it.

What is Processing?

Processing is a flexible software sketchbook and a language for learning how to code within the context of the visual arts. Processing sketches run on the Java Virtual Machine and it’s written using Java syntax. It can also be written in Python (but it still runs on the JVM). Since it runs on the Java Virtual Machine it is able to run on Android devices as well.

YouTube videos

Daniel Shiffman has a very popular YouTube channel that’s called TheCodingTrain. On his channel, Daniel does tutorials and his very popular coding challenges. Those coding challenges are written in p5.js and Processing. p5.js is a JavaScript framework developed by the same people that built the Processing framework for Java (both of these are open source). A lot of the syntax in p5.js and Processing is very similar, or evan the same. The core language is different (Java and JavaScript), but the keywords that come with these two (like draw() and PVector) are the same, so you can benefit from watching his videos. His videos are very entertaining, especially if you like math and problem solving, as that is what he does the best.

IDE

Processing has it’s own code editor which makes developing Processing code very easy. You can find the editor here. The official PRocessing code editor is not the only thing that you can use. Aside from the official editor, a lot of people use Eclipse (for desktop applications) and Android Studio (for Android apps). You can develop Android apps directly from the Processing program, but it doesn’t give you nearly as much options as Android Studio does.

Installing Processing

You can find the official documentation on how to install Processing for Android here, but this is for installing the Processing extension. Now, I’m gonna show you how to use Processing with Android Studio.

Create a Android Studio project like you would usually.

Next, copy android-core.jar to /app/libs, and add it as file dependency to the project:

Now you will create a class that extends the PApllet class. That would look something like this:

And you need to initialise this in the Activity that’s going to be using Processing, like this:

This code has been pulled from android.processing.org, and I recomend you check this website out.

My opinion on using Processing in your Android app

I’ve known of Processing for about a year now. I used it a couple of times for some small desktop apps that I built while I was bored. And I evan built an extremely simple Android app using only Processing, but I’ve never incorporated it in a real app. I am planing to use it on my next project that I’m gonna be starting out next week . I will use it on a small part of my app. I chose Processing because it uses Java syntax, and there is really not mutc to it. It’s really simple to learn if you already know Java, and it’s really really fun to mess around with.

References

Official Android Processing documentation

p5.js

Desktop Processing

Processing.py

TheCodingTrain

Libraries