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

Summary


Thanks to JNI, Java and C/C++ can be tightly integrated together. Android is now fully bilingual! Java can call C/C++ code with any type of data or object, and native code can call Java back.

We also discovered how to call Java code from native code with the JNI Reflection API. Practically any Java operation can be performed from native code thanks to it. However, for best performance, class, method, or field descriptors must be cached.

We also saw how to attach and detach a thread to the VM and synchronize Java and native threads together with JNI monitors. Multithreaded code is probably one of the most difficult subjects in programming. Do it with care!

Finally, we also natively processed bitmaps thanks to JNI, and decoded a video feed by hand. However, an expensive conversion is needed from the default YUV format (which should be supported on every device according to Android specifications) to RGB.

When dealing with native code on Android, JNI is almost always in the way. It is a...