3#include <QtCore/qglobal.h>
4#include <QtCore/qdebug.h>
6#if defined(Q_QDOC) || defined(Q_OS_ANDROID)
8#include <QtCore/qjniobject.h>
9#include <QtCore/qjnitypes.h>
14 QString helloString(
"Hello");
15 jstring myJString = 0;
17 QJniObject string = QJniObject::fromString(helloString);
18 myJString = string.object<jstring>();
22 QString myQtString = QJniObject(myJString).toString();
27static void fromJavaOne(JNIEnv *env, jobject thiz, jint x)
31 qDebug() << x <<
"< 100";
34static void fromJavaTwo(JNIEnv *env, jobject thiz, jint x)
38 qDebug() << x <<
">= 100";
44 const JNINativeMethod methods[] =
45 {{
"callNativeOne",
"(I)V",
reinterpret_cast<
void *>(fromJavaOne)},
46 {
"callNativeTwo",
"(I)V",
reinterpret_cast<
void *>(fromJavaTwo)}};
48 env.registerNativeMethods(
"my/java/project/FooJavaClass", methods, 2);
51 QJniObject::callStaticMethod<
void>(
"my/java/project/FooJavaClass",
"foo",
"(I)V", 10);
52 QJniObject::callStaticMethod<
void>(
"my/java/project/FooJavaClass",
"foo",
"(I)V", 100);
60 public static void foo(
int x)
68private static native
void callNativeOne(
int x);
69private static native
void callNativeTwo(
int x);