JNI语法 JNI参考 JNI函数大全

原文地址:JNI语法 JNI参考 JNI函数大全

内容太多,请按Ctrl+F查找你需要的信息。

 

一、对照表

Java类型    本地类型         描述
boolean    jboolean       C/C++8位整型
byte       jbyte          C/C++带符号的8位整型
char       jchar          C/C++无符号的16位整型
short      jshort         C/C++带符号的16位整型
int        jint           C/C++带符号的32位整型
long       jlong          C/C++带符号的64位整型e
float      jfloat         C/C++32位浮点型
double     jdouble        C/C++64位浮点型
Object     jobject        任何Java对象,或者没有对应java类型的对象
Class      jclass         Class对象
String     jstring        字符串对象
Object[]   jobjectArray   任何对象的数组
boolean[]  jbooleanArray  布尔型数组
byte[]     jbyteArray     比特型数组
char[]     jcharArray     字符型数组
short[]    jshortArray    短整型数组
int[]      jintArray      整型数组
long[]     jlongArray     长整型数组
float[]    jfloatArray    浮点型数组
double[]   jdoubleArray   双浮点型数组

 

 二、JNI函数大全  

来自:http://blog.chinaunix.net/uid-22028680-id-3429721.html

 

1、AndroidJNI.AllocObject 分配对象


static function AllocObject (clazz : IntPtr) : IntPtr
Description描述
Allocates a new Java object without invoking any of the constructors for the object.
分配新 Java 对象而不调用该对象的任何构造函数。返回该对象的引用。
clazz 参数务必不要引用数组类。


2、AndroidJNI.AttachCurrentThread 附加当前线程


static function AttachCurrentThread () : int
Description描述
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[]) : bool
Description描述
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[]) : Byte
Description描述
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[]) : Char
Description描述
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[]) : double
Description描述
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[]) : float
Description描述
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[]) : IntPtr
Description描述
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[]) : Int64
Description描述
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[]) : IntPtr
Description描述
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[]) : Int16
Description描述
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[]) : bool
Description描述
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[]) : Byte
Description描述
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、An

  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值