Obsolete Members for QJniEnvironment
类QJniEnvironment 的以下成员已被弃用。提供这些成员是为了保持旧源代码的正常运行。我们强烈建议不要在新代码中使用它们。
公共函数
(deprecated in 6.2) bool | registerNativeMethods(const char *className, JNINativeMethod[] methods, int size) |
成员函数文档
[deprecated in 6.2]
bool QJniEnvironment::registerNativeMethods(const char *className, JNINativeMethod[] methods, int size)
自 6.2 版起,该函数已被弃用。我们强烈建议不要在新代码中使用该函数。
这是一个重载函数。
使用重载函数时请使用 const JNINativeMethod[]。
在大小为size 的数组methods 中注册 Java 方法,每个方法都可以调用类className 中的本地 C++ 函数。在尝试调用这些方法之前必须先注册。
如果注册成功,则返回true
,否则返回false
。
方法数组中的每个元素包括
- Java 方法名称
- 方法签名
- 将执行的 C++ 函数
JNINativeMethod methods[] = {{"callNativeOne", "(I)V", reinterpret_cast<void *>(fromJavaOne)}, {"callNativeTwo", "(I)V", reinterpret_cast<void *>(fromJavaTwo)}}; QJniEnvironment env; env.registerNativeMethods("org/qtproject/android/TestJavaClass", methods, 2);
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.