`
googlelee
  • 浏览: 114932 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

Android JNI

阅读更多
package test.lee.mymm;

public class MyJNI {

static{
System.loadLibrary("MyMM");
}


public native int add();

}
=====================================
package test.lee.mymm;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class MyMM extends Activity {
    /** Called when the activity is first created. */


private TextView tv1 = null;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
       
        MyJNI myjni = new MyJNI();
        int res = myjni.add();
        String show = String.valueOf(res);
        tv1=(TextView)findViewById(R.id.TextView01);
        tv1.setText(show);
    }
}
====
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)

LOCAL_C_INCLUDES := $(JNI_H_INCLUDE)

LOCAL_SRC_FILES:= \
test_lee_mymm_MyJNI.c

LOCAL_SHARED_LIBRARIES := libutils

LOCAL_PRELINK_MODULE := false

LOCAL_MODULE := libMyMM

include $(BUILD_SHARED_LIBRARY)

====
#include <stdio.h>
#include <stdlib.h>
#include "test_lee_mymm_MyJNI.h"

JNIEXPORT jint JNICALL Java_test_lee_mymm_MyJNI_add
  (JNIEnv* env, jobject obj)
{
return 115;
}
===
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class test_lee_mymm_MyJNI */

#ifndef _Included_test_lee_mymm_MyJNI
#define _Included_test_lee_mymm_MyJNI
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class:     test_lee_mymm_MyJNI
* Method:    add
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_test_lee_mymm_MyJNI_add
  (JNIEnv *, jobject);

#ifdef __cplusplus
}
#endif
#endif
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics