JNI——结构体(即java中的类)的传入与设置——NativeMethod映射表

参考:http://www.cnblogs.com/skywang12345/archive/2013/05/26/3093593.html

java 类:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package com.skywang.ndk;
 
public class MyInfo {
    private String  mName;                    
    private int     mAge;
    private float   mHeight;
     
    public String toString(){
        return "mName:"+mName+", mAge:"+mAge+", mHeight:"+mHeight;
    }
}
============================================
Person.java:
  
package com.skywang.ndk;
 
public class Person {
     
    private String  mName;                    
    private int     mAge;
    private float   mHeight;
     
    public String toString(){
        return "mName:"+mName+", mAge:"+mAge+", mHeight:"+mHeight;
    }
 
}

  

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package com.skywang.ndk;
 
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
 
public class NdkParam extends Activity {
    public static final String TAG="skywang--NdkParam";
    public static final String TAG_MY="MY_skywang--NdkParam";
    /** Called when the activity is first created. */
    private Person person=null;
    private MyInfo myinfo = null;
     
     
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
         
        Log.d(TAG, "on create.");
        person = new Person();
        for (int i=0; i<3; i++) {
            getPersonInfoByIndex(person, i);
            Log.d(TAG, "person["+i+"] -- "+person);
        }
         
        Log.d(TAG, "==============================》MyInfo.《==================================");
        myinfo = new MyInfo();
        for (int i=0; i<3; i++) {
             
            getMyInfoByIndex(myinfo, i);
            Log.d(TAG, "myinfo["+i+"] -- "+myinfo);
        }
    }
     
    // jni
    private native int getPersonInfoByIndex(Person person, int index);
    private native int getMyInfoByIndex(MyInfo myinfo, int index);
 
    static {
        //System.loadLibrary("ndk_param");
        System.loadLibrary("ndk_param");
    }
}

  JNI:

  

  

JNI——结构体(即java中的类)的传入与设置——NativeMethod映射表,布布扣,bubuko.com

JNI——结构体(即java中的类)的传入与设置——NativeMethod映射表

上一篇:SSL证书与Https应用部署小结


下一篇:关于电梯阻塞原因的小思考