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

Calling Java back from native code

In the previous chapter, we have discovered how to get a Java class descriptor with JNI method FindClass() . But we can get much more! Actually, if you are a regular Java developer, this should remind you of something: the Java reflection API. Similarly, JNI can modify Java object fields, run Java methods, access static members... but from native code. This is often referred to as a Java callback, because Java code is run from native code which descends itself from Java. But this is the simple case. Since JNI is tightly coupled with threads, calling Java code from native threads is slightly more difficult. Attaching a thread to a VM is only part of the solution.

For this last part with the Store project, let's ...

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