Android JNI容易实例(android 调用C/C++代码)
Android JNI简单实例(android 调用C/C++代码)
Android的jni实例
android 的应用程序(Dalvik VM)中使用JNI(Java Native Interface)调用C/C++开发的共享库。
c/c++中调用java程序的方法以后再发。
开发环境
(eclipse + android ADT)
WindowsXP SP3
JDK 1.6.0.12
VMWARE+Ubuntu Linux 8.04
(1) Eclipse中新建android工程
工程名 JNItest
Package名com.ura.test
Activity名 JNItest
应用程序名 JNItest
(2) 编辑main.xml
(3)编辑java文件
确认拷贝成功
android 的应用程序(Dalvik VM)中使用JNI(Java Native Interface)调用C/C++开发的共享库。
c/c++中调用java程序的方法以后再发。
开发环境
(eclipse + android ADT)
WindowsXP SP3
JDK 1.6.0.12
VMWARE+Ubuntu Linux 8.04
(1) Eclipse中新建android工程
工程名 JNItest
Package名com.ura.test
Activity名 JNItest
应用程序名 JNItest
(2) 编辑main.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:id="@+id/JNITest" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/JNITest" /> </LinearLayout>
(3)编辑java文件
adb shell adb remount adb push libJNITest.so /system/lib
确认拷贝成功