O'Reilly logo

Android NDK Beginner's Guide by Sylvain Ratabouil

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Referencing Java objects from native code

We know from a previous part that a string is represented in JNI as a jstring , which is in fact a Java object which means that it is possible to exchange Java objects through JNI! But because native code cannot understand or access Java directly, all Java objects have the same representation: a jobject .

In this part, we are going to focus on how to save an object on the native side and how to send it back to Java. In the next project, we are going to work with colors, although any other type of object would work.

Note

Project Store_Part3-1 can be used as a starting point for this part. The resulting project is provided with this book under the name Store_Part3-2.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required