第一个app:
AIDL:
package net.bwie.monthexam; interface IGetCppStringInterface { String getCppString(); }
c++:
#include <jni.h> #include <string> extern "C" JNIEXPORT jstring JNICALL Java_net_bwie_monthexam_MainActivity_stringFromJNI( JNIEnv *env, jobject /* this */) { std::string hello = "Hello from C++"; return env->NewStringUTF(hello.c_str()); } extern "C" JNIEXPORT jstring JNICALL Java_net_bwie_monthexam_service_GetCppStringService_stringFromJNI2( JNIEnv *env, jobject /* this */) { std::string hello = "Hello from C++"; return env->NewStringUTF(hello.c_str()); }
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="net.bwie.monthexam.MainActivity"> <TextView android:id="@+id/sample_text" android:layout_width="wrap_content"