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

Summary

In this chapter, we have seen how to make Java communicate with C/C++. Android is now almost bilingual! Java can call C/C++ code with any type of data or objects. More specifically, we have seen how to call native code with primitive types. These primitives have their C/C++ equivalent type they can can be casted to. Then, we have passed objects and handled their references. References are local to a method by default and should not be shared outside method scope. They should be managed carefully as their number is limited (this limit can still be manually increased). After that, we have shared and stored objects with global references. Global references need to be carefully deleted to ensure proper garbage collection. We have also raised ...

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