-
Book Overview & Buying
-
Table Of Contents
Android Native Development Kit Cookbook
By :
JNI exposes strings, classes, instance objects, and arrays as reference types. The previous recipe introduces the string type. This recipe will cover reference management and the subsequent three recipes will discuss class, object, and arrays respectively.
The following steps create a sample Android project that illustrates reference management in JNI:
Create a project named ManagingReference. Set the package name as cookbook.chapter2. Create an activity named ManagingReferenceActivity. Under the project, create a folder named jni. Refer to the Loading native libraries and registering native methods recipe in this chapter, if you want more detailed instructions.
Create a file named referencetest.c under the jni folder, then implement the
localReference,
globalReference,
weakReference, and
referenceAssignmentAndNew methods. This is shown in the following code snippet:
JNIEXPORT void JNICALL Java_cookbook_chapter2_ManagingReferenceActivity_localReference...
Change the font size
Change margin width
Change background colour