Menu Home

JNI

android程序调用JNI

OS: MAC OS 10.7.5 Android: 4.3 NDK: android-ndk-r7c java: 1.6.0_51 使用JNI 在Eclipse中新建一个Android工程,假设项目目录为project,修改activity_main.xml 如下: <RelativeLayout xmlns:android=”http://schemas.android.com/apk/res/android” xmlns:tools=”http://schemas.android.com/tools” android:layout_width=”match_parent” android:layout_height=”match_parent” android:paddingBottom=”@dimen/activity_vertical_margin” android:paddingLeft=”@dimen/activity_horizontal_margin” android:paddingRight=”@dimen/activity_horizontal_margin” android:paddingTop=”@dimen/activity_vertical_margin” tools:context=”.MainActivity” > <TextView android:id=”@+id/showText” android:layout_width=”wrap_content” android:layout_height=”wrap_content” /> </RelativeLayout> MainActivity.java: package net.lnmcc.usejni; import android.os.Bundle; import android.app.Activity; import android.view.Menu; import android.widget.TextView; public class MainActivity extends Activity { // 加载JNI库 static […]