QAndroidJniEnvironment 类

QAndroidJniEnvironment 提供对 JNI 环境的访问。 更多...

头: #include <QAndroidJniEnvironment>
qmake: QT += androidextras
Since: Qt 5.2

该类在 Qt 5.2 引入。

公共函数

QAndroidJniEnvironment ()
~QAndroidJniEnvironment ()
jclass findClass (const char * className )
JNIEnv * operator JNIEnv * () const
JNIEnv * operator-> ()

静态公共成员

JavaVM * javaVM ()

详细描述

成员函数文档编制

QAndroidJniEnvironment:: QAndroidJniEnvironment ()

构造新的 QAndroidJniEnvironment 对象并将当前线程附加到 Java VM。

bool exceptionCheck()
{
    /*
      The QAndroidJniEnvironment attaches the current thread to the JavaVM on
      creation and detach when it goes out of scope.
     */
    QAndroidJniEnvironment qjniEnv;
    return qjniEnv->ExceptionCheck();
}
					

QAndroidJniEnvironment:: ~QAndroidJniEnvironment ()

分离当前线程从 Java VM 和销毁 QAndroidJniEnvironment 对象。

jclass QAndroidJniEnvironment:: findClass (const char * className )

搜索 className using all available class loaders. Qt on Android uses a custom class loader to load all the .jar files and it must be used to find any classes that are created by that class loader because these classes are not visible in the default class loader.

返回类指针或 null 若没有找到。

A use case for this function is searching for a custom class then calling its memeber method. The following code snippet create an instance of the class CustomClass and then calls printFromJava() 方法:


					

[static] JavaVM *QAndroidJniEnvironment:: javaVM ()

返回 Java VM 接口。

JNIEnv *QAndroidJniEnvironment:: operator JNIEnv * () const

返回 JNI 环境指针。

JNIEnv *QAndroidJniEnvironment:: operator-> ()

提供访问 QAndroidJniEnvironment 的 JNIEnv 指针。