当前位置: 首页>>代码示例>>C++>>正文


C++ QAndroidJniEnvironment类代码示例

本文整理汇总了C++中QAndroidJniEnvironment的典型用法代码示例。如果您正苦于以下问题:C++ QAndroidJniEnvironment类的具体用法?C++ QAndroidJniEnvironment怎么用?C++ QAndroidJniEnvironment使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了QAndroidJniEnvironment类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: callStaticBooleanMethod

void tst_QAndroidJniObject::callStaticBooleanMethod()
{
    QAndroidJniEnvironment env;
    jclass cls = env->FindClass("java/lang/Boolean");
    QVERIFY(cls != 0);

    {
        QAndroidJniObject parameter = QAndroidJniObject::fromString("true");
        QVERIFY(parameter.isValid());

        jboolean b = QAndroidJniObject::callStaticMethod<jboolean>(cls,
                                                            "parseBoolean",
                                                            "(Ljava/lang/String;)Z",
                                                            parameter.object<jstring>());
        QVERIFY(b);
    }

    {
        QAndroidJniObject parameter = QAndroidJniObject::fromString("false");
        QVERIFY(parameter.isValid());

        jboolean b = QAndroidJniObject::callStaticMethod<jboolean>(cls,
                                                            "parseBoolean",
                                                            "(Ljava/lang/String;)Z",
                                                            parameter.object<jstring>());
        QVERIFY(!b);
    }
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:28,代码来源:tst_qandroidjniobject.cpp

示例2: Q_ASSERT

void QLowEnergyControllerPrivate::readDescriptor(
        const QSharedPointer<QLowEnergyServicePrivate> service,
        const QLowEnergyHandle /*charHandle*/,
        const QLowEnergyHandle descriptorHandle)
{
    Q_ASSERT(!service.isNull());

    QAndroidJniEnvironment env;
    bool result = false;
    if (hub) {
        qCDebug(QT_BT_ANDROID) << "Read descriptor with handle"
                               <<  descriptorHandle << service->uuid;
        result = hub->javaObject().callMethod<jboolean>("readDescriptor",
                      "(I)Z", descriptorHandle);
    }

    if (env->ExceptionOccurred()) {
        env->ExceptionDescribe();
        env->ExceptionClear();
        result = false;
    }

    if (!result)
        service->setError(QLowEnergyService::DescriptorReadError);
}
开发者ID:2gis,项目名称:2gisqt5android,代码行数:25,代码来源:qlowenergycontroller_android.cpp

示例3: defined

const QString Wpp::getDownloadPath() const
{
	QString downloadPath;
#if defined(Q_OS_ANDROID)
	//https://qt-project.org/forums/viewthread/35519
	QAndroidJniObject mediaDir = QAndroidJniObject::callStaticObjectMethod("android/os/Environment", "getExternalStorageDirectory", "()Ljava/io/File;");
	QAndroidJniObject mediaPath = mediaDir.callObjectMethod( "getAbsolutePath", "()Ljava/lang/String;" );
	downloadPath = mediaPath.toString()+"/Download/";
	QAndroidJniEnvironment env;
	if (env->ExceptionCheck()) {
		// Handle exception here.
		qDebug() << "[ERR]:Android(Extras):getting SD card download path";
		env->ExceptionClear();
	}
#elif defined(Q_OS_IOS)
	QStringList paths = QStandardPaths::standardLocations(QStandardPaths::DownloadLocation);
	qDebug() << "[IOS]download paths count:" << paths.size();
	downloadPath = paths.first();
#else
	QStringList paths = QStandardPaths::standardLocations(QStandardPaths::DownloadLocation);
	qDebug() << "[Other OS]download paths count:" << paths.size();
	downloadPath = paths.first();

#endif
	qDebug() << "downloadPath:" << downloadPath;
	return downloadPath;
}
开发者ID:AndrewDesign,项目名称:wpp-qt,代码行数:27,代码来源:Wpp.cpp

示例4: fireSupportForumIntent

void AndroidMainWindow::fireSupportForumIntent()
{
#ifdef Q_OS_ANDROID
//    qDebug() << "fireSupportForumIntent()";
    QAndroidJniObject s1 = QAndroidJniObject::fromString("http://mdforum.designer2k2.at/viewtopic.php?f=15&t=334");
    QSettings settings;
    if ( settings.value("md/md", QVariant ( MDMODE ).toBool() )  == false ) {
        s1 = QAndroidJniObject::fromString("http://digifant-einzelabstimmung.de/bofh-ng/de/digifant-1/live-daten-auslesen");
    }


    QAndroidJniObject::callStaticMethod<void>( "de/gummelinformatics/mui/MuiIntentHelper",
                                           "openUrl",
                                           "(Ljava/lang/String;)V",
                                            s1.object<jstring>() );

    QAndroidJniEnvironment env;
    if (env->ExceptionCheck()) {
        // Handle exception here.
        qDebug() << "*** JNI exception ***";
        env->ExceptionDescribe();
        env->ExceptionClear();
        env->ExceptionClear();
    } else {
        qDebug() << "NO JNI exception";
    }

//    QDesktopServices::openUrl( QUrl("http://mdforum.designer2k2.at/") );

#endif
}
开发者ID:landracer,项目名称:multidisplay-app,代码行数:31,代码来源:AndroidMainWindow.cpp

示例5: Q_Q

void QBluetoothSocketPrivate::inputThreadError(int errorCode)
{
    Q_Q(QBluetoothSocket);

    if (errorCode != -1) { //magic error which is expected and can be ignored
        errorString = QBluetoothSocket::tr("Network error during read");
        q->setSocketError(QBluetoothSocket::NetworkError);
    }

    //finally we can delete the InputStreamThread
    InputStreamThread *client = qobject_cast<InputStreamThread *>(sender());
    if (client)
        client->deleteLater();

    if (socketObject.isValid()) {
        //triggered when remote side closed the socket
        //cleanup internal objects
        //if it was call to local close()/abort() the objects are cleaned up already

        QAndroidJniEnvironment env;
        socketObject.callMethod<void>("close");
        if (env->ExceptionCheck()) {
            env->ExceptionDescribe();
            env->ExceptionClear();
        }

        inputStream = outputStream = remoteDevice = socketObject = QAndroidJniObject();
    }

    q->setSocketState(QBluetoothSocket::UnconnectedState);
    q->setOpenMode(QIODevice::NotOpen);
    emit q->disconnected();
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:33,代码来源:qbluetoothsocket_android.cpp

示例6: retrieveDpi

int ScreenValues::retrieveDpi()
{
#ifdef Q_OS_ANDROID
    QAndroidJniEnvironment env;
    env->PushLocalFrame(9);

    QAndroidJniObject activity = QAndroidJniObject::callStaticObjectMethod("org/qtproject/qt5/android/QtNative",
                                                                           "activity",
                                                                           "()Landroid/app/Activity;");

    QAndroidJniObject resources = activity.callObjectMethod("getResources",
                                                            "()Landroid/content/res/Resources;");

    QAndroidJniObject displayMetrics = resources.callObjectMethod("getDisplayMetrics",
                                                                  "()Landroid/util/DisplayMetrics;");

    jint densityDpi = displayMetrics.getField<jint>("densityDpi");

    int result = (int)densityDpi;

    return result;
#else
    return QGuiApplication::primaryScreen()->physicalDotsPerInch();
#endif
}
开发者ID:ivanph,项目名称:qtworldsummit,代码行数:25,代码来源:screenvalues.cpp

示例7: cleanJavaException

void cleanJavaException()
{
    QAndroidJniEnvironment env;
    if (env->ExceptionCheck()) {
        env->ExceptionDescribe();
        env->ExceptionClear();
    }
}
开发者ID:KamalGalrani,项目名称:qgroundcontrol,代码行数:8,代码来源:qserialport_android.cpp

示例8: getStaticByteField

void tst_QAndroidJniObject::getStaticByteField()
{
    QAndroidJniEnvironment env;
    jclass cls = env->FindClass("java/lang/Byte");
    QVERIFY(cls != 0);

    jbyte i = QAndroidJniObject::getStaticField<jbyte>(cls, "MAX_VALUE");
    QCOMPARE(i, jbyte(127));
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:9,代码来源:tst_qandroidjniobject.cpp

示例9: getStaticIntField

void tst_QAndroidJniObject::getStaticIntField()
{
    QAndroidJniEnvironment env;
    jclass cls = env->FindClass("java/lang/Double");
    QVERIFY(cls != 0);

    jint i = QAndroidJniObject::getStaticField<jint>(cls, "SIZE");
    QCOMPARE(i, 64);
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:9,代码来源:tst_qandroidjniobject.cpp

示例10: getStaticShortField

void tst_QAndroidJniObject::getStaticShortField()
{
    QAndroidJniEnvironment env;
    jclass cls = env->FindClass("java/lang/Short");
    QVERIFY(cls != 0);

    jshort i = QAndroidJniObject::getStaticField<jshort>(cls, "MAX_VALUE");
    QCOMPARE(i, jshort(32767));
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:9,代码来源:tst_qandroidjniobject.cpp

示例11: onRegisterNativeMethods

void QQmlAndroidScrollView::onRegisterNativeMethods(jobject listener)
{
    JNINativeMethod methods[] {{"onScrollChanged", "(JII)V", reinterpret_cast<void *>(onScrollChanged)}};

    QAndroidJniEnvironment env;
    jclass cls = env->GetObjectClass(listener);
    env->RegisterNatives(cls, methods, sizeof(methods) / sizeof(methods[0]));
    env->DeleteLocalRef(cls);
}
开发者ID:butzist,项目名称:playground-qtqmlandroid,代码行数:9,代码来源:qqmlandroidscrollview.cpp

示例12: getStaticCharField

void tst_QAndroidJniObject::getStaticCharField()
{
    QAndroidJniEnvironment env;
    jclass cls = env->FindClass("java/lang/Character");
    QVERIFY(cls != 0);

    jchar i = QAndroidJniObject::getStaticField<jchar>(cls, "MAX_VALUE");
    QCOMPARE(i, jchar(0xffff));
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:9,代码来源:tst_qandroidjniobject.cpp

示例13: getStaticLongField

void tst_QAndroidJniObject::getStaticLongField()
{
    QAndroidJniEnvironment env;
    jclass cls = env->FindClass("java/lang/Long");
    QVERIFY(cls != 0);

    jlong i = QAndroidJniObject::getStaticField<jlong>(cls, "MAX_VALUE");
    QCOMPARE(i, jlong(9223372036854775807L));
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:9,代码来源:tst_qandroidjniobject.cpp

示例14: exceptionCheck

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();
}
开发者ID:SchleunigerAG,项目名称:WinEC7_Qt5.3.1_Fixes,代码行数:9,代码来源:src_androidextras_qandroidjnienvironment.cpp

示例15: getStaticDoubleField

void tst_QAndroidJniObject::getStaticDoubleField()
{
    QAndroidJniEnvironment env;
    jclass cls = env->FindClass("java/lang/Double");
    QVERIFY(cls != 0);

    jdouble i = QAndroidJniObject::getStaticField<jdouble>(cls, "NaN");
    jlong *k = reinterpret_cast<jlong*>(&i);
    QCOMPARE(*k, jlong(0x7ff8000000000000L));
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:10,代码来源:tst_qandroidjniobject.cpp


注:本文中的QAndroidJniEnvironment类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。