-
Book Overview & Buying
-
Table Of Contents
Android Native Development Kit Cookbook
By :
We have demonstrated how to pass parameters of different types to native methods and return data back to Java. This is not the only way of sharing data between the native code and Java code. This recipe covers another method—accessing Java fields from the native code.
We're going to cover how to access Java fields of different types, including primitive types, strings, instance objects, and arrays. The following recipes should be read first before reading this recipe:
Passing parameters and receiving returns in primitive types
Manipulating strings in JNI
Manipulating classes in JNI
Manipulating objects in JNI
Manipulating arrays in JNI
Readers are also expected to be familiar with Java reflection API.
Follow these steps to create a sample Android project that demonstrates how to access Java static and instance fields from the native code:
Create a project named AccessingFields. Set the package name as cookbook...
Change the font size
Change margin width
Change background colour