Game Development Reference
In-Depth Information
Application Architecture
Let's consider what we wish to accomplish with this application:
•
We want to create the basic Android application. When run in the emulator, the
app will create a default view with the text “Hello Chapter2!”.
•
Within the project, we will create a native folder with files to accomplish the
following:
Create a native library with a main subroutine that will be called from the
Android main activity using JNI.
•
The main library subroutine will invoke a Java method (using JNI) within the
Android project, sending a text message back to the Android Java layer.
•
The library will be loaded at runtime within Java using a
System.load(path)
.
Figure 2-5 shows the file system layout of the project.
•
■
Tip
It would be helpful to import the project source (
ch02.Project
) into your workspace to go along with this
chapter.
The following Java files describe the project:
ch02.project.MainActivity.java
: This file is created by the wizard and should
already exist in the project.
•
jni.Natives.java
: This is a new file that contains native methods to be invoked
within the native library and callbacks that the C library will perform within Java.
•