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[] 参数的重载版本。

将数组methods 中大小为size 的Java方法进行注册,其中每个方法都可以调用类className 中的本机C++函数。在尝试调用这些方法之前,必须先对其进行注册。

若注册成功,则返回true ;否则返回false 。

methods数组中的每个元素包含:

  • 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);

这是一个重载函数。

© 2026 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.