Game Development Reference
In-Depth Information
Figure 11-2. Cygwin Unix command shell for Windows
Ways to Use the Android NDK
There are two ways to use the Android NDK.
Use the Android Java framework and use the Java Native Interface or JNI to call
native code from your Java-based Android program.
Use the NativeActivity class provided by the Android SDK to replace normally
Java language life cycle callbacks such as onCreate() , onPause() , onResume() ,
etc., with native code written in C/C++. However, native activities must be run
on Android operating system versions 2.3 (API Level 9) and higher. Also, some
Android framework services cannot be accessed natively.
In this chapter, I will cover using the JNI to access native code from the Java framework.
Java Native Interface Overview
The JNI allows Java code that runs within the Android virtual machine to operate with applications
and libraries written in other programming languages, such as C, C++, and assembly. The Java
Interface Pointer is discussed in this section. Native C/C++ coding methods are treated, including
the variable types used with the JNI, the required naming conventions for native C/C++ functions,
and the required input parameters for these functions. The procedure to integrate native functions
into Java code is given. Examples of how to use native code from Java and how to use Java
functions from native code are also presented in this section.
 
Search WWH ::




Custom Search