Book Image

Android NDK: Beginner's Guide

By : Sylvain Ratabouil
Book Image

Android NDK: Beginner's Guide

By: Sylvain Ratabouil

Overview of this book

Table of Contents (18 chapters)
Android NDK Beginner's Guide Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Referencing Java objects from native code


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

In this part, we will focus on how to save an object on the native side and how to send it back to Java. As an example, we will work with a custom object Color, although any other type of object would work too.

Note

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