码迷,mamicode.com
首页 > 编程语言 > 详细

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

时间:2014-05-09 00:10:19      阅读:687      评论:0      收藏:0      [点我收藏+]

标签:android   blog   class   code   java   ext   

参考: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映射表

标签:android   blog   class   code   java   ext   

原文地址:http://www.cnblogs.com/Miami/p/3716533.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!