Walking through a hands on JNI example project to help you with Android JNI programming.
Month: December 2017
Android JNI – NIO and Reflection Support
NIO Support The NIO-related entry points allow native code to access java.nio direct buffers. The contents of a direct buffer can, potentially, reside in native memory outside of the ordinary garbage-collected heap. For information about direct buffers, please see New I/O APIs and the specification of the java.nio.ByteBuffer class. Three new functions introduced in JDK/JRE 1.4 allow JNI code to create, …
Android .gitignore template
Provide a .gitignore template for android project.
Some handy notes for git common operations
Android Build Commands
Install apk In case that you have both simulator and device connected but you want to install the app on device, then use the global option "-d" just right after the "adb" command will help. Update existing apk on device. Uninstall apk Run instrumented tests Run all tests Run a particular test class Run …
Android JNI – Array Operations
Array OperationsGetArrayLength Returns the number of elements in the array. NewObjectArray Constructs a new array holding objects in class elementClass. All elements are initially set to initialElement. GetObjectArrayElement Returns an element of an Object array. SetObjectArrayElement Sets an element of an Object array. New<PrimitiveType>Array Routines A family of operations used to construct a new primitive array object. Below describes the specific primitive …
Android JNI – String Operations
String OperationsNewString Constructs a new java.lang.String object from an array of Unicode characters. GetStringLength GetStringChars Returns a pointer to the array of Unicode characters of the string. This pointer is valid until ReleaseStringchars() is called. If isCopy is not NULL, then *isCopy is set to JNI_TRUE if a copy is made; or it is set to JNI_FALSE if no copy is made. ReleaseStringChars Informs the VM that the …
Android JNI – Object Operations
Object OperationsAllocObject Allocates a new Java object without invoking any of the constructors for the object. Returns a reference to the object. The clazz argument must not refer to an array class. NewObject NewObjectA NewObjectV Constructs a new Java object. The method ID indicates which constructor method to invoke. This ID must be obtained by …
Android JNI – Class Operations, Exceptions and References
Class OperationsDefineClass Android does not use Java bytecodes or class files, so passing in binary class data doesn't work. FindClass The name argument is a fully-qualified class name or an array type signature. For example, the fully-qualified class name for the java.lang.String class is: "java/lang/String" ExceptionsThrow Causes a java.lang.Throwable object to be thrown. ThrowNew Constructs an exception …
Continue reading Android JNI – Class Operations, Exceptions and References
Android JNI – Overview
An overview of Android JNI programming from Arophix.