开发学院手机开发Android 开发 Android NDK动态库的调用 阅读

Android NDK动态库的调用

 2010-09-16 23:50:00 来源:WEB开发网   
核心提示:* function.*/TextView tv = new TextView(this);int a = getinformation();String lls = a +"";tv.setText(lls);setContentView(tv);}/* A native method that

* function.

*/

TextView tv = new TextView(this);

int a = getinformation();

String lls = a +"";

tv.setText(lls);

setContentView(tv);

}

/* A native method that is implemented by the

* 'hello-jni' native library, which is packaged

* with this application.

*/

public native int getinformation();

/* this is used to load the 'hello-jni' library on application

* startup. The library has already been unpacked into

* /data/data/com.example.HelloJni/lib/libhello-jni.so at

* installation time by the package manager.

*/

static {

System.loadLibrary("test");

}

}

Android.mk LOCAL_PATH := $(call my-dir)

#获取当前目录

include $(CLEAR_VARS)

#清除一些变量

LOCAL_MODULE := tutorial

#要生成的库名

LOCAL_SRC_FILES := tutorial01.c tutorial02.c

#库对应的源文件

include $(BUILD_SHARED_LIBRARY)

#生成动态库libtutorial.so

include $(CLEAR_VARS)

#清除一些变量

LOCAL_MODULE := test

#定义另外一个库的名

LOCAL_SRC_FILES := test01.c

#定义库对应的源文件

LOCAL_LDLIBS := -ldl -llog

#libtest.so需要引用的库libdl.so:加载动态函数需要,liblog.so 日志打印需要,默认是system/lib目录下

include $(BUILD_SHARED_LIBRARY)

#生成共享库

test01.c

#include

#include

#include

#include

#include

#define LOG_TAG "libgl2jni"

#define LOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)

#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__)

//extern int getinformation();

jint Java_com_example_test_test01_getinformation(JNIEnv* env,jobject

上一页  1 2 3 4 5 6 7  下一页

Tags:Android NDK 动态

编辑录入:coldstar [复制链接] [打 印]
[]
  • 好
  • 好的评价 如果觉得好,就请您
      0%(0)
  • 差
  • 差的评价 如果觉得差,就请您
      0%(0)
赞助商链接