[DllImport("sqleet", EntryPoint= "execute_test")] public st
[DllImport("sqleet", EntryPoint= "execute_test")]
public static extern string execute_test(string path);
//java
[DllImport("native-lib", EntryPoint = "Java_com_km_demo_myapplication_MainActivity_stringFromJNI")]
public extern static IntPtr stringFromJNI(IntPtr env, IntPtr thiz);
//java
[DllImport("hello", EntryPoint = "Java_com_km_demo_myapplication_hello_add")] //省略掉lib前缀和.so 后缀
//public static extern int add(IntPtr env, IntPtr thiz, int i, int j);
[DllImport("hello")] //省略掉lib前缀和.so 后缀
public static extern int add( int i, int j);
[DllImport("hello")] //省略掉lib前缀和.so 后缀
public static extern string getString(string str);
//java 字符串
var zz = stringFromJNI(System.IntPtr.Zero, System.IntPtr.Zero);
Java.Lang.String ss = Java.Lang.Object.GetObject(zz, JniHandleOwnership.TransferLocalRef);
//普通字符串
string str = getString("abc");
java
#include
#include
extern "C" JNIEXPORT jstring JNICALL Java_com_km_demo_myapplication_MainActivity_stringFromJNI(
JNIEnv* env,
jobject ) {
std::string hello = "Hello from c++";
return env->NewStringUTF(hello.c_str());
}
//
// Created by Administrator on 2020/3/18.
//
#include
#ifndef _Included_com_km_demo_myapplication_hello
#define _Included_com_km_demo_myapplication_hello
#ifdef __cplusplus
extern "C" {
#endif
JNIEXPORT jint JNICALL Java_com_km_demo_myapplication_hello_add
(JNIEnv *, jobject, jint i, jint j){
return i+j;
}
int add(int i, int j){
return i+j;
}
#ifdef __cplusplus
}
#endif
#endif
--结束END--
本文标题: Xamarin.Android 引用so
本文链接: https://www.lsjlt.com/news/29282.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-01-21
2023-10-28
2023-10-28
2023-10-27
2023-10-27
2023-10-27
2023-10-27
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0