Passing Java primitives to native code

The simplest kinds of elements we can handle with JNI are Java primitive types. Indeed, both the Java and native side use practically the same representation for this kind of data which, does not require any specific memory management.

In this part, we will see how to pass integers to the native side and send them back to the Java side.

Note

The resulting project is provided with this book under the name Store_Part6.

Get Android NDK Beginner's Guide - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.