JNI的語法

jayqiu發表於2018-08-30

##1.在C/C++中實現本地方法

生成C/C++標頭檔案之後,你就需要寫標頭檔案對應的本地方法。注意:所有的本地方法的第一個引數都是指向JNIEnv結構的。這個結構是用來呼叫JNI函式的。第二個引數jclass的意義,要看方法是不是靜態的(static)或者例項(Instance)的。前者,jclass代表一個類物件的引用,而後者是被呼叫的方法所屬物件的引用。

返回值和引數型別根據等價約定對映到本地C/C++型別,如表JNI型別對映所示。有些型別,在原生程式碼中可直接使用,而其他型別只有通過JNI呼叫操作。

abiao.png
##2.JNI函式大全

#####1、AndroidJNI.AllocObject 分配物件 static function AllocObject (clazz : IntPtr) : IntPtrDescription描述Allocates a new Java object without invoking any of the constructors for the object.分配新 Java 物件而不呼叫該物件的任何建構函式。返回該物件的引用。clazz 引數務必不要引用陣列類。 #####2、AndroidJNI.AttachCurrentThread 附加當前執行緒 static function AttachCurrentThread () : intDescription描述Attaches the current thread to a Java (Dalvik) VM.附加當前執行緒到一個Java(Dalvik)虛擬機器。A thread must be attached to the VM before any other JNI calls can be made.一個執行緒必須附加到虛擬機器,在任何其他JNI可呼叫之前。Returns 0 on success; returns a negative number on failure.成功返回0,失敗返回一個負數。 #####3、AndroidJNI.CallBooleanMethod 呼叫布林方法 static function CallBooleanMethod (obj : IntPtr, methodID : IntPtr, args : jvalue[]) : boolDescription描述Calls an instance (nonstatic) Java method defined by methodID, optionally passing an array of arguments (args) to the method.呼叫一個由methodID定義的例項的Java方法,可選擇傳遞引數(args)的陣列到這個方法。 #####4、AndroidJNI.CallByteMethod 呼叫位元組方法 static function CallByteMethod (obj : IntPtr, methodID : IntPtr, args : jvalue[]) : ByteDescription描述Calls an instance (nonstatic) Java method defined by methodID, optionally passing an array of arguments (args) to the method. 呼叫一個由methodID定義的例項的Java方法,可選擇傳遞引數(args)的陣列到這個方法。

#####5、AndroidJNI.CallCharMethod 呼叫字元方法 static function CallCharMethod (obj : IntPtr, methodID : IntPtr, args : jvalue[]) : CharDescription描述Calls an instance (nonstatic) Java method defined by methodID, optionally passing an array of arguments (args) to the method.呼叫一個由methodID定義的例項的Java方法,可選擇傳遞引數(args)的陣列到這個方法。 #####6、AndroidJNI.CallDoubleMethod 呼叫雙精度浮點數方法 static function CallDoubleMethod (obj : IntPtr, methodID : IntPtr, args : jvalue[]) : doubleDescription描述Calls an instance (nonstatic) Java method defined by methodID, optionally passing an array of arguments (args) to the method.呼叫一個由methodID定義的例項的Java方法,可選擇傳遞引數(args)的陣列到這個方法。 #####7、AndroidJNI.CallFloatMethod 呼叫浮點數方法 static function CallFloatMethod (obj : IntPtr, methodID : IntPtr, args : jvalue[]) : floatDescription描述Calls an instance (nonstatic) Java method defined by methodID, optionally passing an array of arguments (args) to the method.呼叫一個由methodID定義的例項的Java方法,可選擇傳遞引數(args)的陣列到這個方法。 #####8、AndroidJNI.CallIntMethod 呼叫整數方法 static function CallObjectMethod (obj : IntPtr, methodID : IntPtr, args : jvalue[]) : IntPtrDescription描述Calls an instance (nonstatic) Java method defined by methodID, optionally passing an array of arguments (args) to the method.呼叫一個由methodID定義的例項的Java方法,可選擇傳遞引數(args)的陣列到這個方法。 #####9、AndroidJNI.CallLongMethod 呼叫長整數方法 static function CallLongMethod (obj : IntPtr, methodID : IntPtr, args : jvalue[]) : Int64Description描述Calls an instance (nonstatic) Java method defined by methodID, optionally passing an array of arguments (args) to the method.呼叫一個由methodID定義的例項的Java方法,可選擇傳遞引數(args)的陣列到這個方法。 #####10、AndroidJNI.CallObjectMethod 呼叫物件方法 static function CallObjectMethod (obj : IntPtr, methodID : IntPtr, args : jvalue[]) : IntPtrDescription描述Calls an instance (nonstatic) Java method defined by methodID, optionally passing an array of arguments (args) to the method.呼叫一個由methodID定義的例項的Java方法,可選擇傳遞引數(args)的陣列到這個方法。This method returns a reference to a java.lang.Object, or a subclass thereof.這個方法返回一個引用到java.lang.Object,或者其子類。 #####11、AndroidJNI.CallShortMethod 呼叫短整數方法 static function CallShortMethod (obj : IntPtr, methodID : IntPtr, args : jvalue[]) : Int16Description描述Calls an instance (nonstatic) Java method defined by methodID, optionally passing an array of arguments (args) to the method.呼叫一個由methodID定義的例項的Java方法,可選擇傳遞引數(args)的陣列到這個方法。 #####12、AndroidJNI.CallStaticBooleanMethod 呼叫靜態布林方法 static function CallStaticBooleanMethod (clazz : IntPtr, methodID : IntPtr, args : jvalue[]) : boolDescription描述Invokes a static method on a Java object, according to the specified methodID, optionally passing an array of arguments (args) to the method.在一個Java物件呼叫一個靜態方法,根據指定的methodID,可選傳遞引數(args)的陣列到該方法。 #####13、AndroidJNI.CallStaticByteMethod 呼叫靜態位元組方法 static function CallStaticByteMethod (clazz : IntPtr, methodID : IntPtr, args : jvalue[]) : ByteDescription描述Invokes a static method on a Java object, according to the specified methodID, optionally passing an array of arguments (args) to the method.在一個Java物件呼叫一個靜態方法,根據指定的methodID,可選傳遞引數(args)的陣列到該方法。 #####14、AndroidJNI.CallStaticCharMethod 呼叫靜態字元方法 static function CallStaticCharMethod (clazz : IntPtr, methodID : IntPtr, args : jvalue[]) : CharDescription描述Invokes a static method on a Java object, according to the specified methodID, optionally passing an array of arguments (args) to the method.在一個Java物件呼叫一個靜態方法,根據指定的methodID,可選傳遞引數(args)的陣列到該方法。 #####15、AndroidJNI.CallStaticDoubleMethod 呼叫靜態雙精度浮點數方法 static function CallStaticDoubleMethod (clazz : IntPtr, methodID : IntPtr, args : jvalue[]) : doubleDescription描述Invokes a static method on a Java object, according to the specified methodID, optionally passing an array of arguments (args) to the method.在一個Java物件呼叫一個靜態方法,根據指定的methodID,可選傳遞引數(args)的陣列到該方法。 #####16、AndroidJNI.CallStaticFloatMethod 呼叫靜態浮點數方法 static function CallStaticFloatMethod (clazz : IntPtr, methodID : IntPtr, args : jvalue[]) : floatDescription描述Invokes a static method on a Java object, according to the specified methodID, optionally passing an array of arguments (args) to the method.在一個Java物件呼叫一個靜態方法,根據指定的methodID,可選傳遞引數(args)的陣列到該方法。 #####17、AndroidJNI.CallStaticIntMethod 呼叫靜態整數方法 static function CallStaticIntMethod (clazz : IntPtr, methodID : IntPtr, args : jvalue[]) : Int32Description描述Invokes a static method on a Java object, according to the specified methodID, optionally passing an array of arguments (args) to the method.在一個Java物件呼叫一個靜態方法,根據指定的methodID,可選傳遞引數(args)的陣列到該方法。 #####18、AndroidJNI.CallStaticLongMethod 呼叫靜態長整數方法 static function CallStaticLongMethod (clazz : IntPtr, methodID : IntPtr, args : jvalue[]) : Int64Description描述Invokes a static method on a Java object, according to the specified methodID, optionally passing an array of arguments (args) to the method.在一個Java物件呼叫一個靜態方法,根據指定的methodID,可選傳遞引數(args)的陣列到該方法。 #####19、AndroidJNI.CallStaticObjectMethod 呼叫靜態物件方法 static function CallStaticObjectMethod (clazz : IntPtr, methodID : IntPtr, args : jvalue[]) : IntPtrDescription描述Invokes a static method on a Java object, according to the specified methodID, optionally passing an array of arguments (args) to the method.在一個Java物件呼叫一個靜態方法,根據指定的methodID,可選傳遞引數(args)的陣列到該方法。This method returns a reference to a java.lang.Object, or a subclass thereof.這個方法返回一個java.lang.Object的引用,或者其子類。 #####20、AndroidJNI.CallStaticShortMethod 呼叫靜態短整數方法 static function CallStaticShortMethod (clazz : IntPtr, methodID : IntPtr, args : jvalue[]) : Int16Description描述Invokes a static method on a Java object, according to the specified methodID, optionally passing an array of arguments (args) to the method.在一個Java物件呼叫一個靜態方法,根據指定的methodID,可選傳遞引數(args)的陣列到該方法。 #####21、AndroidJNI.CallStaticStringMethod 呼叫靜態字串方法 static function CallStaticStringMethod (clazz : IntPtr, methodID : IntPtr, args : jvalue[]) : stringDescription描述Invokes a static method on a Java object, according to the specified methodID, optionally passing an array of arguments (args) to the method.在一個Java物件呼叫一個靜態方法,根據指定的methodID,可選傳遞引數(args)的陣列到該方法。This is a convenience function that calls CallStaticObjectMethod() with the same parameters, but creates a managed string from the result.這是一個方便的函式,呼叫帶有相同引數的CallStaticObjectMethod(),但從該結果建立一個託管字串。 #####22、AndroidJNI.CallStaticVoidMethod 呼叫靜態無型別方法 static function CallStaticVoidMethod (clazz : IntPtr, methodID : IntPtr, args : jvalue[]) : voidDescription描述Invokes a static method on a Java object, according to the specified methodID, optionally passing an array of arguments (args) to the method. 在一個Java物件呼叫一個靜態方法,根據指定的methodID,可選傳遞引數(args)的陣列到該方法。

#####23、AndroidJNI.CallStringMethod 呼叫字串方法 static function CallStringMethod (obj : IntPtr, methodID : IntPtr, args : jvalue[]) : stringDescription描述Calls an instance (nonstatic) Java method defined by methodID, optionally passing an array of arguments (args) to the method.呼叫一個由methodID定義的例項的Java方法,可選擇傳遞引數(args)的陣列到這個方法。This is a convenience function that calls CallObjectMethod() with the same parameters, but creates a managed string from the result.這是一個方便的函式,呼叫帶有相同引數的CallObjectMethod(),但從整個結果建立一個託管字串。 #####24、AndroidJNI.CallVoidMethod 呼叫無型別方法 static function CallVoidMethod (obj : IntPtr, methodID : IntPtr, args : jvalue[]) : voidDescription描述Calls an instance (nonstatic) Java method defined by methodID, optionally passing an array of arguments (args) to the method.呼叫一個由methodID定義的例項的Java方法,可選擇傳遞引數(args)的陣列到這個方法。 #####25、AndroidJNI.DeleteGlobalRef 刪除全域性引用 static function DeleteGlobalRef (obj : IntPtr) : voidDescription描述Deletes the global reference pointed to by obj.刪除 obj 所指向的全域性引用。 #####26、AndroidJNI.DeleteLocalRef 刪除區域性引用 static function DeleteLocalRef (obj : IntPtr) : voidDescription描述Deletes the local reference pointed to by obj.刪除 obj 所指向的區域性引用。 #####27、AndroidJNI.DetachCurrentThread 分離當前執行緒 static function DetachCurrentThread () : intDescription描述Detaches the current thread from a Java (Dalvik) VM.從一個Java(Dalvik)虛擬機器,分類當前執行緒。A thread must be detached from the VM before exiting.從退出虛擬機器之前,一個執行緒必須被分類。 #####28、AndroidJNI.EnsureLocalCapacity 確保區域性效能 static function EnsureLocalCapacity (capacity : int) : intDescription描述Ensures that at least a given number of local references can be created in the current thread.在當前執行緒確保至少一個可以被建立的給定區域性引用數。 #####29、AndroidJNI.ExceptionClear 清除異常 static function ExceptionClear () : voidDescription描述Clears any exception that is currently being thrown.清除當前丟擲的任何異常。如果當前無異常,則此例程不產生任何效果。 #####30、AndroidJNI.ExceptionDescribe 描述異常 static function ExceptionDescribe () : voidDescription描述Prints an exception and a backtrace of the stack to the logcat將異常及堆疊的回溯輸出到系統錯誤報告通道。該例程可便利除錯操作。 #####31、AndroidJNI.ExceptionOccurred 發生異常 static function ExceptionOccurred () : IntPtrDescription描述Determines if an exception is being thrown確定是否某個異常正被丟擲。 #####32、AndroidJNI.FatalError 致命錯誤 static function FatalError (message : string) : voidDescription描述Raises a fatal error and does not expect the VM to recover. This function does not return.丟擲致命錯誤並且不希望虛擬機器進行修復。該函式無返回值。 #####33、AndroidJNI.FindClass 查詢類 static function FindClass (name : string) : IntPtrDescription描述This function loads a locally-defined class.這個函式載入一個本地定義的類。 #####34、AndroidJNI.FromBooleanArray 從布林陣列 static function FromBooleanArray (array : IntPtr) : Boolean[]Description描述Convert a Java array of boolean to a managed array of System.Boolean.轉換一個Java布林陣列到一個託管System.Boolean陣列。 #####35、AndroidJNI.FromByteArray 從位元組陣列 static function FromByteArray (array : IntPtr) : Byte[]Description描述Convert a Java array of byte to a managed array of System.Byte.轉換一個Java位元組陣列到一個託管的System.Byte陣列。 #####36、AndroidJNI.FromCharArray 從字元陣列 static function FromCharArray (array : IntPtr) : Char[]Description描述Convert a Java array of char to a managed array of System.Char.轉換一個Java字元陣列到一個託管的System.Char陣列。 #####37、AndroidJNI.FromDoubleArray 從雙精度浮點數陣列 static function FromDoubleArray (array : IntPtr) : double[]Description描述Convert a Java array of double to a managed array of System.Double.轉換一個Java雙精度浮點數陣列到一個託管的System.Double陣列。 #####38、AndroidJNI.FromFloatArray 從浮點數陣列 static function FromFloatArray (array : IntPtr) : float[]Description描述Convert a Java array of float to a managed array of System.Single.轉換一個Java浮點數陣列到一個託管的System.Single陣列。 #####39、AndroidJNI.FromIntArray 從整數陣列 static function FromIntArray (array : IntPtr) : Int32[]Description描述Convert a Java array of int to a managed array of System.Int32.轉換一個Java整數陣列到一個託管的System.Int32陣列。 #####40、AndroidJNI.FromLongArray 從整長數陣列 static function FromLongArray (array : IntPtr) : Int64[]Description描述Convert a Java array of long to a managed array of System.Int64.轉換一個Java長整數陣列到一個託管的System.Int64陣列。 #####41、AndroidJNI.FromObjectArray 從物件陣列 static function FromObjectArray (array : IntPtr) : IntPtr[]Description描述Convert a Java array of java.lang.Object to a managed array of System.IntPtr, representing Java objects轉換一個Java的java.lang.Object陣列到一個託管的System.IntPtr陣列,表示Java物件。 #####42、AndroidJNI.FromReflectedField 來自反射的域 static function FromReflectedField (refField : IntPtr) : IntPtrDescription描述Converts a java.lang.reflect.Field to a field ID.轉換一個java.lang.reflect.Field到一個域ID。 #####43、AndroidJNI.FromReflectedMethod 來自反射的方法 static function FromReflectedMethod (refMethod : IntPtr) : IntPtrDescription描述Converts a java.lang.reflect.Method or java.lang.reflect.Constructor object to a method ID.轉換一個java.lang.reflect.Method或java.lang.reflect.Constructor物件到一個方法ID。 #####44、AndroidJNI.FromShortArray 從短整數陣列 static function FromShortArray (array : IntPtr) : Int16[]Description描述Convert a Java array of short to a managed array of System.Int16. 轉換一個Java短整數陣列到一個託管的System.Int16陣列。

#####45、AndroidJNI.GetArrayLength 獲取陣列長度 static function GetArrayLength (array : IntPtr) : intDescription描述Returns the number of elements in the array.返回陣列的元素數。 #####46、AndroidJNI.GetBooleanArrayElement 獲取布林陣列元素 static function GetBooleanArrayElement (array : IntPtr, index : int) : boolDescription描述Returns the value of one element of a primitive array.返回一個基本陣列一個元素的值。This function is a special case of GetBooleanArrayRegion(), called with region size set to 1.這個函式是一個特殊情況的GetBooleanArrayRegion(),就是region大小設定為1時。 #####47、AndroidJNI.GetBooleanField 獲取布林域 static function GetBooleanField (obj : IntPtr, fieldID : IntPtr) : boolDescription描述This function returns the value of an instance (nonstatic) field of an object.這個函式返回一個物件例項(非靜態)域的值。 #####48、AndroidJNI.GetByteArrayElement 獲取位元組陣列元素 static function GetByteArrayElement (array : IntPtr, index : int) : ByteDescription描述Returns the value of one element of a primitive array.返回一個基本陣列一個元素的值。This function is a special case of GetByteArrayRegion(), called with region size set to 1.這個函式是一個特殊情況的GetByteArrayRegion(),就是region大小設定為1時。 #####49、AndroidJNI.GetByteField 獲取位元組域 static function GetByteField (obj : IntPtr, fieldID : IntPtr) : ByteDescription描述This function returns the value of an instance (nonstatic) field of an object.這個函式返回一個物件例項(非靜態)域的值。 #####50、AndroidJNI.GetCharArrayElement 獲取字元陣列元素 static function GetCharArrayElement (array : IntPtr, index : int) : CharDescription描述Returns the value of one element of a primitive array.返回一個基本陣列一個元素的值。This function is a special case of GetCharArrayRegion(), called with region size set to 1.這個函式是一個特殊情況的GetCharArrayRegion(),就是region大小設定為1時。 #####51、AndroidJNI.GetCharField 獲取字元域 static function GetCharField (obj : IntPtr, fieldID : IntPtr) : CharDescription描述This function returns the value of an instance (nonstatic) field of an object.這個函式返回一個物件例項(非靜態)域的值。 #####52、AndroidJNI.GetDoubleArrayElement 獲取雙精度浮點數陣列元素 static function GetDoubleArrayElement (array : IntPtr, index : int) : doubleDescription描述Returns the value of one element of a primitive array.返回一個基本陣列一個元素的值。This function is a special case of GetDoubleArrayRegion(), called with region size set to 1.這個函式是一個特殊情況的GetDoubleArrayRegion(),就是region大小設定為1時。 #####53、AndroidJNI.GetDoubleField 獲取雙精度浮點數域 static function GetDoubleField (obj : IntPtr, fieldID : IntPtr) : doubleDescription描述This function returns the value of an instance (nonstatic) field of an object.這個函式返回一個物件例項(非靜態)域的值。 #####54、AndroidJNI.GetFieldID 獲取域ID static function GetFieldID (clazz : IntPtr, name : string, sig : string) : IntPtrDescription描述Returns the field ID for an instance (nonstatic) field of a class.返回類的例項(非靜態)域的域 ID。該域由其名稱及簽名指定。GetFieldID() 將未初始化的類初始化。 #####55、AndroidJNI.GetFloatArrayElement 獲取浮點數陣列元素 static function GetFloatArrayElement (array : IntPtr, index : int) : floatDescription描述Returns the value of one element of a primitive array.返回一個基本陣列一個元素的值。This function is a special case of GetFloatArrayRegion(), called with region size set to 1.這個函式是一個特殊情況的GetFloatArrayRegion(),就是region大小設定為1時。 #####56、AndroidJNI.GetFloatField 獲取浮點數域 static function GetFloatField (obj : IntPtr, fieldID : IntPtr) : floatDescription描述This function returns the value of an instance (nonstatic) field of an object.這個函式返回一個物件例項(非靜態)域的值。 #####57、AndroidJNI.GetIntArrayElement 獲取整數陣列元素 static function GetIntArrayElement (array : IntPtr, index : int) : Int32Description描述Returns the value of one element of a primitive array.返回一個基本陣列一個元素的值。This function is a special case of GetIntArrayRegion(), called with region size set to 1.這個函式是一個特殊情況的GetIntArrayRegion(),就是region大小設定為1時。 #####58、AndroidJNI.GetIntField 獲取整數域 static function GetIntField (obj : IntPtr, fieldID : IntPtr) : Int32Description描述This function returns the value of an instance (nonstatic) field of an object.這個函式返回一個物件例項(非靜態)域的值。 #####59、AndroidJNI.GetLongArrayElement 獲取長整數陣列元素 static function GetLongArrayElement (array : IntPtr, index : int) : Int64Description描述Returns the value of one element of a primitive array.返回一個基本陣列一個元素的值。This function is a special case of GetLongArrayRegion(), called with region size set to 1.這個函式是一個特殊情況的GetLongArrayRegion(),就是region大小設定為1時。 #####60、AndroidJNI.GetLongField 獲取長整數域 static function GetLongField (obj : IntPtr, fieldID : IntPtr) : Int64Description描述This function returns the value of an instance (nonstatic) field of an object.這個函式返回一個物件例項(非靜態)域的值。 #####61、AndroidJNI.GetMethodID 獲取方法ID static function GetMethodID (clazz : IntPtr, name : string, sig : string) : IntPtrDescription描述Returns the method ID for an instance (nonstatic) method of a class or interface.返回類或介面例項(非靜態)方法的方法 ID。方法可在某個 clazz 的超類中定義,也可從 clazz 繼承。該方法由其名稱和簽名決定。GetMethodID() 可使未初始化的類初始化。 #####62、AndroidJNI.GetObjectArrayElement 獲取物件陣列元素 static function GetObjectArrayElement (array : IntPtr, index : int) : IntPtrDescription描述Returns an element of an Object array.返回一個物件陣列的一個元素。 #####63、AndroidJNI.GetObjectClass 獲取物件類 static function GetObjectClass (obj : IntPtr) : IntPtrDescription描述Returns the class of an object.返回一個物件的類。 #####64、AndroidJNI.GetObjectField 獲取物件域 static function GetObjectField (obj : IntPtr, fieldID : IntPtr) : IntPtrDescription描述This function returns the value of an instance (nonstatic) field of an object.這個函式返回一個物件例項(非靜態)域的值。The result is a reference to a java.lang.Object, or a subclass thereof.其結果是對一個java.lang.Object的引用,或者其子類。 #####65、AndroidJNI.GetShortArrayElement 獲取短整數陣列元素 static function GetShortArrayElement (array : IntPtr, index : int) : Int16Description描述Returns the value of one element of a primitive array.返回一個基本陣列一個元素的值。This function is a special case of GetShortArrayRegion(), called with region size set to 1.這個函式是一個特殊情況的GetShortArrayRegion(),就是region大小設定為1時。 #####66、AndroidJNI.GetShortField 獲取短整數域 static function GetShortField (obj : IntPtr, fieldID : IntPtr) : Int16Description描述This function returns the value of an instance (nonstatic) field of an object.這個函式返回一個物件例項(非靜態)域的值。 #####67、AndroidJNI.GetStaticBooleanField 獲取靜態布林域 static function GetStaticBooleanField (clazz : IntPtr, fieldID : IntPtr) : boolDescription描述This function returns the value of a static field of an object.這個函式返回一個物件靜態域的值。 #####68、AndroidJNI.GetStaticByteField 獲取靜態位元組域 static function GetStaticByteField (clazz : IntPtr, fieldID : IntPtr) : ByteDescription描述This function returns the value of a static field of an object.這個函式返回一個物件靜態域的值。 #####69、AndroidJNI.GetStaticCharField 獲取靜態字元域 static function GetStaticCharField (clazz : IntPtr, fieldID : IntPtr) : CharDescription描述This function returns the value of a static field of an object.這個函式返回一個物件靜態域的值。 #####70、AndroidJNI.GetStaticDoubleField 獲取靜態雙精度浮點數域 static function GetStaticDoubleField (clazz : IntPtr, fieldID : IntPtr) : doubleDescription描述This function returns the value of a static field of an object.這個函式返回一個物件靜態域的值。 #####71、AndroidJNI.GetStaticFieldID 獲取靜態域ID static function GetStaticFieldID (clazz : IntPtr, name : string, sig : string) : IntPtrDescription描述Returns the field ID for a static field of a class.返回類的靜態域的域 ID。域由其名稱和簽名指定。GetStaticFieldID() 將未初始化的類初始化。 #####72、AndroidJNI.GetStaticFloatField 獲取靜態浮點數域 static function GetStaticFloatField (clazz : IntPtr, fieldID : IntPtr) : floatDescription描述This function returns the value of a static field of an object.這個函式返回一個物件靜態域的值。 #####73、AndroidJNI.GetStaticIntField 獲取靜態整數域 static function GetStaticIntField (clazz : IntPtr, fieldID : IntPtr) : Int64Description描述This function returns the value of a static field of an object.這個函式返回一個物件靜態域的值。 #####74、AndroidJNI.GetStaticLongField 獲取靜態長整數域 static function GetStaticLongField (clazz : IntPtr, fieldID : IntPtr) : Int64Description描述This function returns the value of a static field of an object.這個函式返回一個物件靜態域的值。 #####75、AndroidJNI.GetStaticMethodID 獲取靜態方法ID static function GetStaticMethodID (clazz : IntPtr, name : string, sig : string) : IntPtrDescription描述Returns the method ID for a static method of a class.返回類的靜態方法的方法 ID。方法由其名稱和簽名指定。GetStaticMethodID() 將未初始化的類初始化。 #####76、AndroidJNI.GetStaticObjectField 獲取靜態物件域 static function GetStaticObjectField (clazz : IntPtr, fieldID : IntPtr) : IntPtrDescription描述This function returns the value of a static field of an object.這個函式返回一個物件靜態域的值。The result is a reference to a java.lang.Object, or a subclass thereof.該結果是一個java.lang.Object的引用,或者其子類。 #####77、AndroidJNI.GetStaticShortField 獲取靜態短整數域 static function GetStaticShortField (clazz : IntPtr, fieldID : IntPtr) : Int16Description描述This function returns the value of a static field of an object.這個函式返回一個物件靜態域的值。 #####78、AndroidJNI.GetStaticStringField 獲取靜態字串域 static function GetStaticStringField (clazz : IntPtr, fieldID : IntPtr) : stringDescription描述This function returns the value of a static field of an object.這個函式返回一個物件靜態域的值。This is a convenience function that calls GetStaticObjectField() with the same parameters, but creates a managed string from the result.這是一個方便的函式,呼叫帶有相同引數的GetStaticObjectField(),但從該結果建立一個託管字串。 #####79、AndroidJNI.GetStringField 獲取字串域 static function GetStringField (obj : IntPtr, fieldID : IntPtr) : stringDescription描述This function returns the value of an instance (nonstatic) field of an object.這個函式返回一個物件例項(非靜態)域的值。This is a convenience function that calls GetObjectField() with the same parameters, but creates a managed string from the result.這是一個方便的函式,呼叫帶有相同引數的GetObjectField(),但從結果建立一個託管字串。 #####80、AndroidJNI.GetStringUTFChars 獲取字串UTF的字元 static function GetStringUTFChars (str : IntPtr) : stringDescription描述Returns a managed string object representing the string in modified UTF-8 encoding.返回由UTF-8修改的託管的字串物件。另解,返回指向字串的 UTF-8 字元陣列的指標。This method is a modification of the original GetStringUTFChars, which returns a pointer to an array of bytes.這個方法是原始GetStringUTFChars的修改,返回指向位元組的陣列。 #####81、AndroidJNI.GetStringUTFLength 獲取字串UTF的長度 static function GetStringUTFLength (str : IntPtr) : intDescription描述Returns the length in bytes of the modified UTF-8 representation of a string.以位元組為單位返回字串的 UTF-8 長度。 #####82、AndroidJNI.GetSuperclass 獲取超類 static function GetSuperclass (clazz : IntPtr) : IntPtrDescription描述If clazz represents any class other than the class Object, then this function returns the object that represents the superclass of the class specified by clazz.如果 clazz 代表類而非類 object,則該函式返回由 clazz 所指定的類的超類。If clazz specifies the class Object, or clazz represents an interface, this function returns NULL.如果 clazz 指定類 Object,或代表某個介面,則該函式返回 NULL。 #####83、AndroidJNI.GetVersion 獲取版本 static function GetVersion () : intDescription描述Returns the version of the native method interface.返回本地方法介面的版本。 #####84、AndroidJNI.IsAssignableFrom 是否可賦值 static function IsAssignableFrom (clazz1 : IntPtr, clazz2 : IntPtr) : boolDescription描述Determines whether an object of clazz1 can be safely cast to clazz2.確定 clazz1 的物件是否可安全地強制轉換為 clazz2。 #####85、AndroidJNI.IsInstanceOf 是否某類的例項 static function IsInstanceOf (obj : IntPtr, clazz : IntPtr) : boolDescription描述Tests whether an object is an instance of a class.測試物件是否為某個類的例項。 #####86、AndroidJNI.IsSameObject 是否同一物件 static function IsSameObject (obj1 : IntPtr, obj2 : IntPtr) : boolDescription描述Tests whether two references refer to the same Java object.測試兩個引用是否引用同一 Java 物件。 #####87、AndroidJNI.NewBooleanArray 新建布林陣列 static function NewBooleanArray (size : int) : IntPtrDescription描述Construct a new primitive array object.構造一個新的基本陣列物件。 #####88、AndroidJNI.NewByteArray 新建位元組陣列 static function NewByteArray (size : int) : IntPtrDescription描述Construct a new primitive array object.構造一個新的基本陣列物件。 #####89、AndroidJNI.NewCharArray 新建字元陣列 static function NewCharArray (size : int) : IntPtrDescription描述Construct a new primitive array object.構造一個新的基本陣列物件。 #####90、AndroidJNI.NewDoubleArray 新建雙精度浮點數陣列 static function NewDoubleArray (size : int) : IntPtrDescription描述Construct a new primitive array object.構造一個新的基本陣列物件。 #####91、AndroidJNI.NewFloatArray 新建浮點數陣列 static function NewFloatArray (size : int) : IntPtrDescription描述Construct a new primitive array object.構造一個新的基本陣列物件。 #####92、AndroidJNI.NewGlobalRef 新建全域性引用 static function NewGlobalRef (obj : IntPtr) : IntPtrDescription描述Creates a new global reference to the object referred to by the obj argument.建立 obj 引數所引用物件的新全域性引用。全域性引用通過呼叫 DeleteGlobalRef() 來顯式撤消。返回全域性引用。如果系統記憶體不足則返回 NULL。 #####93、AndroidJNI.NewIntArray 新建整數陣列 static function NewIntArray (size : int) : IntPtrDescription描述Construct a new primitive array object.構造一個新的基本陣列物件。 #####94、AndroidJNI.NewLocalRef 新建區域性引用 static function NewLocalRef (obj : IntPtr) : IntPtrDescription描述Creates a new local reference that refers to the same object as obj.建立 obj 引數物件的新區域性引用。 #####95、AndroidJNI.NewLongArray 新建長整數陣列 static function NewLongArray (size : int) : IntPtrDescription描述Construct a new primitive array object. 構造一個新的基本陣列物件。 #####96、AndroidJNI.NewObjectArray 新建物件陣列 static function NewObjectArray (size : int, clazz : IntPtr, obj : IntPtr) : IntPtrDescription描述Constructs a new array holding objects in class clazz. All elements are initially set to obj.構造新的陣列,它將儲存在類 clazz 中的物件。所有元素初始值均設為 obj。 #####97、AndroidJNI.NewObject 新建物件 static function NewObject (clazz : IntPtr, methodID : IntPtr, args : jvalue[]) : IntPtrDescription描述Constructs a new Java object. The method ID indicates which constructor method to invoke. This ID must be obtained by calling GetMethodID() with as the method name and void (V) as the return type.構造新的 Java 物件。方法 ID指示應呼叫的建構函式方法。該 ID 必須通過呼叫 GetMethodID() 獲得,且呼叫時的方法名必須為 ,而返回型別必須為 void (V)。clazz 引數務必不要引用陣列類。98、AndroidJNI.NewShortArray 新建短整數陣列 static function NewShortArray (size : int) : IntPtrDescription描述Construct a new primitive array object.構造一個新的基本陣列物件。 #####99、AndroidJNI.NewStringUTF 新建UTF字串 static function NewStringUTF (bytes : string) : IntPtrDescription描述Constructs a new java.lang.String object from an array of characters in modified UTF-8 encoding.利用 UTF-8 字元陣列構造新的 java.lang.String 物件。 #####100、AndroidJNI.PopLocalFrame 彈出區域性幀 static function PopLocalFrame (result : IntPtr) : IntPtrDescription描述Pops off the current local reference frame, frees all the local references, and returns a local reference in the previous local reference frame for the given result object.彈出關閉當前區域性引用幀,釋放所有的本地引用,並返回一個區域性引用,在前一個區域性引用幀,用於給定的結果物件。    PushLocalFrame為一定數量的區域性引用建立了一個使用堆疊,而PopLocalFrame負責銷燬堆疊頂端的引用。    Push/PopLocalFrame函式對提供了對區域性引用的生命週期更方便的管理。    在管理區域性引用的生命週期中,Push/PopLocalFrame是非常方便的。你可以在本地函式的入口處呼叫PushLocalFrame,然後在出 口處呼叫PopLocalFrame,這樣的話,在函式對中間任何位置建立的區域性引用都會被釋放。而且,這兩個函式是非常高效的。    如果你在函式的入口處呼叫了PushLocalFrame,記住在所有的出口(有return出現的地方)呼叫PopLocalFrame。    大量的區域性引用建立會浪費不必要的記憶體。一個區域性引用會導致它本身和它所指向的物件都得不到回收。尤其要注意那些長時間執行的方法、建立區域性引用的迴圈和工具函式,充分得利用Pus/PopLocalFrame來高效地管理區域性引用。 #####101、AndroidJNI.PushLocalFrame 壓入區域性幀 static function PushLocalFrame (capacity : int) : intDescription描述Creates a new local reference frame, in which at least a given number of local references can be created.建立一個新的區域性引入幀,至少一個給定的區域性引用可以被建立的數。    PushLocalFrame為一定數量的區域性引用建立了一個使用堆疊,而PopLocalFrame負責銷燬堆疊頂端的引用。    Push/PopLocalFrame函式對提供了對區域性引用的生命週期更方便的管理。    在管理區域性引用的生命週期中,Push/PopLocalFrame是非常方便的。你可以在本地函式的入口處呼叫PushLocalFrame,然後在出 口處呼叫PopLocalFrame,這樣的話,在函式對中間任何位置建立的區域性引用都會被釋放。而且,這兩個函式是非常高效的。    如果你在函式的入口處呼叫了PushLocalFrame,記住在所有的出口(有return出現的地方)呼叫PopLocalFrame。    大量的區域性引用建立會浪費不必要的記憶體。一個區域性引用會導致它本身和它所指向的物件都得不到回收。尤其要注意那些長時間執行的方法、建立區域性引用的迴圈和工具函式,充分得利用Pus/PopLocalFrame來高效地管理區域性引用。 #####102、AndroidJNI.SetBooleanArrayElement 設定布林陣列陣列元素 static function SetBooleanArrayElement (array : IntPtr, index : int, val : byte) : voidDescription描述Sets the value of one element in a primitive array.設定一個基本陣列一個元素的值。This function is a special case of SetBooleanArrayRegion(), called with region size set to 1.這個函式是一個特殊情況的SetBooleanArrayRegion(),就是region大小設定為1時。 #####103、AndroidJNI.SetBooleanField 設定布林域 static function SetBooleanField (obj : IntPtr, fieldID : IntPtr, val : bool) : voidDescription描述This function sets the value of an instance (nonstatic) field of an object.這個函式設定一個物件例項(非靜態)域的值。 #####104、AndroidJNI.SetByteArrayElement 設定位元組陣列元素 static function SetByteArrayElement (array : IntPtr, index : int, val : sbyte) : voidDescription描述Sets the value of one element in a primitive array.設定一個基本陣列一個元素的值。This function is a special case of SetByteArrayRegion(), called with region size set to 1.這個函式是一個特殊情況的SetByteArrayRegion(),就是region大小設定為1時。 #####106、AndroidJNI.SetByteField 設定位元組域 static function SetByteField (obj : IntPtr, fieldID : IntPtr, val : Byte) : voidDescription描述This function sets the value of an instance (nonstatic) field of an object.這個函式設定一個物件例項(非靜態)域的值。 #####107、AndroidJNI.SetCharArrayElement 設定字元陣列元素 static function SetCharArrayElement (array : IntPtr, index : int, val : Char) : voidDescription描述Sets the value of one element in a primitive array.設定一個基本陣列一個元素的值。This function is a special case of SetCharArrayRegion(), called with region size set to 1.這個函式是一個特殊情況的SetCharArrayRegion(),就是region大小設定為1時。 #####108、AndroidJNI.SetCharField 設定字元域 static function SetCharField (obj : IntPtr, fieldID : IntPtr, val : Char) : voidDescription描述This function sets the value of an instance (nonstatic) field of an object.這個函式設定一個物件例項(非靜態)域的值。 #####109、AndroidJNI.SetDoubleArrayElement 設定雙精度浮點數陣列元素 static function SetDoubleArrayElement (array : IntPtr, index : int, val : double) : voidDescription描述Sets the value of one element in a primitive array.設定一個基本陣列一個元素的值。This function is a special case of SetDoubleArrayRegion(), called with region size set to 1.這個函式是一個特殊情況的SetDoubleArrayRegion(),就是region大小設定為1時。 #####110、AndroidJNI.SetDoubleField 設定雙精度浮點數域 static function SetDoubleField (obj : IntPtr, fieldID : IntPtr, val : double) : voidDescription描述This function sets the value of an instance (nonstatic) field of an object.這個函式設定一個物件例項(非靜態)域的值。 #####111、AndroidJNI.SetFloatArrayElement 設定浮點數陣列元素 static function SetFloatArrayElement (array : IntPtr, index : int, val : float) : voidDescription描述Sets the value of one element in a primitive array.設定一個基本陣列一個元素的值。This function is a special case of SetFloatArrayRegion(), called with region size set to 1.這個函式是一個特殊情況的SetFloatArrayRegion(),就是region大小設定為1時。 #####112、AndroidJNI.SetFloatField 設定浮點數域 static function SetFloatField (obj : IntPtr, fieldID : IntPtr, val : float) : voidDescription描述This function sets the value of an instance (nonstatic) field of an object.這個函式設定一個物件例項(非靜態)域的值。 #####113、AndroidJNI.SetIntArrayElement 設定整數陣列元素 static function SetIntArrayElement (array : IntPtr, index : int, val : Int32) : voidDescription描述Sets the value of one element in a primitive array.設定一個基本陣列一個元素的值。This function is a special case of SetIntArrayRegion(), called with region size set to 1.這個函式是一個特殊情況的SetIntArrayRegion(),就是region大小設定為1時。 #####114、AndroidJNI.SetIntField 設定整數域 static function SetIntField (obj : IntPtr, fieldID : IntPtr, val : Int32) : voidDescription描述This function sets the value of an instance (nonstatic) field of an object.這個函式設定一個物件例項(非靜態)域的值。 #####115、AndroidJNI.SetLongArrayElement 設定長整數陣列元素 static function SetLongArrayElement (array : IntPtr, index : int, val : Int64) : voidDescription描述Sets the value of one element in a primitive array.設定一個基本陣列一個元素的值。This function is a special case of SetLongArrayRegion(), called with region size set to 1.這個函式是一個特殊情況的SetLongArrayRegion(),就是region大小設定為1時。 #####116、AndroidJNI.SetLongField 設定長整數域 static function SetLongField (obj : IntPtr, fieldID : IntPtr, val : Int64) : voidDescription描述This function sets the value of an instance (nonstatic) field of an object.這個函式設定一個物件例項(非靜態)域的值。 #####117、AndroidJNI.SetObjectArrayElement 設定物件陣列元素 static function SetObjectArrayElement (array : IntPtr, index : int, obj : IntPtr) : voidDescription描述Sets an element of an Object array.設定一個物件陣列的一個元素。 #####118、AndroidJNI.SetObjectField 設定物件域 static function SetObjectField (obj : IntPtr, fieldID : IntPtr, val : IntPtr) : voidDescription描述This function sets the value of an instance (nonstatic) field of an object.這個函式設定一個物件例項(非靜態)域的值。The value to set is a reference to either a java.lang.Object, or a subclass thereof.要設定的值無論是一個java.lang.Object的引用,或者其子類。 #####119、AndroidJNI.SetShortArrayElement 設定短整數陣列元素 static function SetShortArrayElement (array : IntPtr, index : int, val : Int16) : voidDescription描述Sets the value of one element in a primitive array.設定一個基本陣列一個元素的值。This function is a special case of SetShortArrayRegion(), called with region size set to 1.這個函式是一個特殊情況的SetShortArrayRegion(),就是region大小設定為1時。 #####120、AndroidJNI.SetShortField 設定短整數域 static function SetShortField (obj : IntPtr, fieldID : IntPtr, val : Int16) : voidDescription描述This function sets the value of an instance (nonstatic) field of an object.這個函式設定一個物件例項(非靜態)域的值。 #####121、AndroidJNI.SetStaticBooleanField 設定靜態布林域 static function SetStaticBooleanField (clazz : IntPtr, fieldID : IntPtr, val : bool) : voidDescription描述This function ets the value of a static field of an object.這個函式設定一個物件的靜態域的值。 #####122、AndroidJNI.SetStaticByteField 設定靜態位元組域 static function SetStaticByteField (clazz : IntPtr, fieldID : IntPtr, val : Byte) : voidDescription描述This function ets the value of a static field of an object.這個函式設定一個物件的靜態域的值。 #####123、AndroidJNI.SetStaticCharField 設定靜態字元域 static function SetStaticCharField (clazz : IntPtr, fieldID : IntPtr, val : Char) : voidDescription描述This function ets the value of a static field of an object.這個函式設定一個物件的靜態域的值。 #####124、AndroidJNI.SetStaticDoubleField 設定靜態雙精度浮點數域 static function SetStaticDoubleField (clazz : IntPtr, fieldID : IntPtr, val : double) : voidDescription描述This function ets the value of a static field of an object.這個函式設定一個物件的靜態域的值。

#####125、AndroidJNI.SetStaticFloatField 設定靜態浮點數域 static function SetStaticFloatField (clazz : IntPtr, fieldID : IntPtr, val : float) : voidDescription描述This function ets the value of a static field of an object.這個函式設定一個物件的靜態域的值。 #####126、AndroidJNI.SetStaticIntField 設定靜態整數域 static function SetStaticIntField (clazz : IntPtr, fieldID : IntPtr, val : Int32) : voidDescription描述This function ets the value of a static field of an object.這個函式設定一個物件的靜態域的值。 #####127、AndroidJNI.SetStaticLongField 設定靜態長整數域 static function SetStaticLongField (clazz : IntPtr, fieldID : IntPtr, val : Int64) : voidDescription描述This function ets the value of a static field of an object.這個函式設定一個物件的靜態域的值。 #####128、AndroidJNI.SetStaticObjectField 設定靜態物件域 static function SetStaticObjectField (clazz : IntPtr, fieldID : IntPtr, val : IntPtr) : voidDescription描述This function ets the value of a static field of an object.這個函式設定一個物件的靜態域的值。The value to set is a reference to either a java.lang.Object, or a subclass thereof.設定該值不管是一個java.lang.Object的引用,或是其子類。 #####129、AndroidJNI.SetStaticShortField 設定靜態短整數域 static function SetStaticShortField (clazz : IntPtr, fieldID : IntPtr, val : Int16) : voidDescription描述This function ets the value of a static field of an object.這個函式設定一個物件的靜態域的值。 #####130、AndroidJNI.SetStaticStringField 設定靜態字串域 static function SetStaticStringField (clazz : IntPtr, fieldID : IntPtr, val : string) : voidDescription描述This function ets the value of a static field of an object.這個函式設定一個物件的靜態域的值。This is a convenience function that calls SetStaticObjectField() with the same parameters, but performs the necessary marshalling of the string value.這是一個方便的函式,呼叫帶有相同引數的SetStaticObjectField(),但執行需要字串的值編組。 #####131、AndroidJNI.SetStringField 設定字串域 static function SetStringField (obj : IntPtr, fieldID : IntPtr, val : string) : voidDescription描述This function sets the value of an instance (nonstatic) field of an object.這個函式設定一個物件例項(非靜態)域的值。This is a convenience function that calls SetObjectField() with the same parameters, but performs the necessary marshalling of the string value.這是一個方便的函式,呼叫帶有相同引數的SetObjectField(),但執行字串的值需要編組。 #####132、AndroidJNI.ThrowNew 新的丟擲 static function ThrowNew (clazz : IntPtr, message : string) : intDescription描述Constructs an exception object from the specified class with the message specified by message and causes that exception to be thrown.利用指定類的訊息(由 message 指定)構造異常物件並丟擲該異常。 #####133、AndroidJNI.Throw 丟擲 static function Throw (obj : IntPtr) : intDescription描述Causes a java.lang.Throwable object to be thrown.導致一個java.lang.Throwable的物件被丟擲。

#####134、AndroidJNI.ToBooleanArray 到布林陣列 static function ToBooleanArray (array : Boolean[]) : IntPtrDescription描述Convert a managed array of System.Boolean to a Java array of boolean.轉換一個System.Boolean的託管陣列到一個Java布林陣列。 #####135、AndroidJNI.ToByteArray 到位元組陣列 static function ToByteArray (array : Byte[]) : IntPtrDescription描述Convert a managed array of System.Byte to a Java array of byte.轉換一個System.Byte的託管陣列到一個Java的位元組陣列。 #####136、AndroidJNI.ToCharArray 到字元陣列 static function ToCharArray (array : Char[]) : IntPtrDescription描述Convert a managed array of System.Char to a Java array of char.轉換一個System.Char的託管陣列到一個Java的字元陣列。 #####137、AndroidJNI.ToDoubleArray 到雙精度浮點數陣列 static function ToDoubleArray (array : double[]) : IntPtrDescription描述Convert a managed array of System.Double to a Java array of double.轉換一個System.Double的託管陣列到一個Java的雙精度浮點數陣列。 #####138、AndroidJNI.ToFloatArray 到浮點數陣列 static function ToFloatArray (array : float[]) : IntPtrDescription描述Convert a managed array of System.Single to a Java array of float.轉換一個System.Single的託管陣列到一個Java的浮點數陣列。 #####139、AndroidJNI.ToIntArray 到整數陣列 static function ToIntArray (array : Int32[]) : IntPtrDescription描述Convert a managed array of System.Int32 to a Java array of int.轉換一個System.Int32的託管陣列到一個Java的整數陣列。 #####140、AndroidJNI.ToLongArray 到長整數陣列 static function ToLongArray (array : Int64[]) : IntPtrDescription描述Convert a managed array of System.Int64 to a Java array of long.轉換一個System.Int64的託管陣列到一個Java的長整數陣列。 #####141、AndroidJNI.ToObjectArray 到物件陣列 static function ToObjectArray (array : IntPtr[]) : IntPtrDescription描述Convert a managed array of System.IntPtr, representing Java objects, to a Java array of java.lang.Object.轉換一個System.IntPtr的託管陣列,表示Java物件,到一個Java的java.lang.Object陣列。 #####142、AndroidJNI.ToReflectedField 到反射的域 static function ToReflectedField (clazz : IntPtr, fieldID : IntPtr, isStatic : bool) : IntPtrDescription描述Converts a field ID derived from cls to a java.lang.reflect.Field object.轉換一個取自clazz的域ID到一個java.lang.reflect.Field物件。 #####143、AndroidJNI.ToReflectedMethod 到反射的方法 static function ToReflectedMethod (clazz : IntPtr, methodID : IntPtr, isStatic : bool) : IntPtrDescription描述Converts a method ID derived from clazz to a java.lang.reflect.Method or java.lang.reflect.Constructor object.轉換一個取自clazz的方法ID到一個java.lang.reflect.Method 或 java.lang.reflect.Constructor物件。 #####144、AndroidJNI.ToShortArray 到短整數陣列 static function ToShortArray (array : Int16[]) : IntPtrDescription描述Convert a managed array of System.Int16 to a Java array of short.轉換一個System.Int16的託管陣列到一個Java的短整數陣列。 來自:學而不思則罔,思而不學則貽

相關文章