You are on page 1of 2

Bo co trn LAB Cng vic : Thc hin gi NDK trong android 1.ci t NDK 2.

chy chng trnh hellojni 3.tnh tng 2 s Em to file cpp.c +file Android.mk trong chng trnh hellojni va file add.c + add.h+ file Android.mk File cpp.c co code nhu sau
#include <string.h> #include <jni.h> jstring Java_com_example_MainActivity_getMessage ( JNIEnv* env, jobject thiz ) { return (*env)->NewStringUTF(env, "Hello from JNI !"); } Tng t file add.c code nhu sau

#include "com_marakana_NativeLib.h" JNIEXPORT jstring JNICALL Java_com_marakana_NativeLib_hello (JNIEnv * env, jobject obj) { return (*env)->NewStringUTF(env, "Hello World!"); } JNIEXPORT jint JNICALL Java_com_marakana_NativeLib_add (JNIEnv * env, jobject obj, jint value1, jint value2) { return (value1 + value2); }

You might also like