美文网首页
ndk开发技巧

ndk开发技巧

作者: 千浪 | 来源:发表于2020-12-09 13:35 被阅读0次

/data/local/tmp/

我们编译的Android可执行程序可以放入 /data/local/tmp/ 目录执行,但是可执行文件依赖so时,需要使用以下方式执行:

  1. 首先把so文件也push到/data/local/tmp/ 目录
  2. Then just set LD_LIBRARY_PATH to point at that directory:
LD_LIBRARY_PATH=. ./your_executable_file

获取jobject的className

    // First get the class object
    jmethodID mid = spEnv.get()->GetMethodID(cls, "getClass", "()Ljava/lang/Class;");
    jobject clsObj = spEnv.get()->CallObjectMethod(obj, mid);

    // Now get the class object's class descriptor
    cls = spEnv.get()->GetObjectClass(clsObj);

    // Find the getName() method on the class object
    mid = spEnv.get()->GetMethodID(cls, "getName", "()Ljava/lang/String;");

    // Call the getName() to get a jstring object back
    jstring strObj = (jstring)spEnv.get()->CallObjectMethod(clsObj, mid);

    // Now get the c string from the java jstring object
    const char* str = spEnv.get()->GetStringUTFChars(strObj, NULL);

    // Print the class name
    AJ_LOGE("Calling class is: %s", str);
    
    // Release the memory pinned char array
    // spEnv.get()->ReleaseStringUTFChars(strObj, str);

相关文章

网友评论

      本文标题:ndk开发技巧

      本文链接:https://www.haomeiwen.com/subject/fxdhgktx.html