📑 JNI 使用基础

Security Classification: 【C-1】 | Publish Time:2024-02-01 | Category:Coding | Edit

Expiry Notice: The article was published three months ago. Please independently assess the validity of the technical methods and code mentioned within. :)

AI摘要:本文介绍了如何在Native层通过JNI将复杂对象传递给Java层。首先,定义了一个Device的内部类,并在Native层使用jobject类型返回该对象。通过env->findclass方法找到Java类,并通过clazz与getMethodID获取构造方法。构造方法的参数为三个String类型的值,这些值通过jstring定义并通过NewObject方法返回对象。接着,展示了如何在Native层调用Java层的方法。示例代码中,找到指定类及方法,创建jstring参数并调用sendReq方法。最后,释放字符串参数的引用。 --- (来自模型:gpt-4o-mini-2024-07-18)


Comment List

© Copyright: This article is an original work and the copyright belongs to the  Depy's docs  unless marked as Reproduced

Please contact the blogger for authorization to reprint

『📕Category 』