本文整理汇总了C++中QAndroidJniEnvironment::GetStaticMethodID方法的典型用法代码示例。如果您正苦于以下问题:C++ QAndroidJniEnvironment::GetStaticMethodID方法的具体用法?C++ QAndroidJniEnvironment::GetStaticMethodID怎么用?C++ QAndroidJniEnvironment::GetStaticMethodID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QAndroidJniEnvironment
的用法示例。
在下文中一共展示了QAndroidJniEnvironment::GetStaticMethodID方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fallBackConnect
bool QBluetoothSocketPrivate::fallBackConnect(QAndroidJniObject uuid, int channel)
{
qCWarning(QT_BT_ANDROID) << "Falling back to workaround.";
QAndroidJniEnvironment env;
jclass remoteDeviceClazz = env->GetObjectClass(remoteDevice.object());
jmethodID getClassMethod = env->GetMethodID(remoteDeviceClazz, "getClass", "()Ljava/lang/Class;");
if (!getClassMethod) {
qCWarning(QT_BT_ANDROID) << "BluetoothDevice.getClass method could not be found.";
return false;
}
QAndroidJniObject remoteDeviceClass = QAndroidJniObject(env->CallObjectMethod(remoteDevice.object(), getClassMethod));
if (!remoteDeviceClass.isValid()) {
qCWarning(QT_BT_ANDROID) << "Could not invoke BluetoothDevice.getClass.";
return false;
}
jclass classClass = env->FindClass("java/lang/Class");
jclass integerClass = env->FindClass("java/lang/Integer");
jfieldID integerType = env->GetStaticFieldID(integerClass, "TYPE", "Ljava/lang/Class;");
jobject integerObject = env->GetStaticObjectField(integerClass, integerType);
if (!integerObject) {
qCWarning(QT_BT_ANDROID) << "Could not get Integer.TYPE";
return false;
}
jobjectArray paramTypes = env->NewObjectArray(1, classClass, integerObject);
if (!paramTypes) {
qCWarning(QT_BT_ANDROID) << "Could not create new Class[]{Integer.TYPE}";
return false;
}
QAndroidJniObject parcelUuid("android/os/ParcelUuid", "(Ljava/util/UUID;)V",
uuid.object());
if (parcelUuid.isValid()) {
jint socketChannel = remoteDevice.callMethod<jint>("getServiceChannel",
"(Landroid/os/ParcelUuid;)I",
parcelUuid.object());
if (env->ExceptionCheck()) {
env->ExceptionDescribe();
env->ExceptionClear();
}
if (socketChannel
== remoteDevice.getStaticField<jint>("android/bluetooth/BluetoothDevice", "ERROR")) {
qCWarning(QT_BT_ANDROID) << "Cannot determine RFCOMM service channel.";
} else {
qCWarning(QT_BT_ANDROID) << "Using found rfcomm channel" << socketChannel;
channel = socketChannel;
}
}
QAndroidJniObject method = remoteDeviceClass.callObjectMethod(
"getMethod",
"(Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method;",
QAndroidJniObject::fromString(QLatin1String("createRfcommSocket")).object<jstring>(),
paramTypes);
if (!method.isValid() || env->ExceptionCheck()) {
qCWarning(QT_BT_ANDROID) << "Could not invoke getMethod";
if (env->ExceptionCheck()) {
env->ExceptionDescribe();
env->ExceptionClear();
}
return false;
}
jclass methodClass = env->GetObjectClass(method.object());
jmethodID invokeMethodId = env->GetMethodID(
methodClass, "invoke",
"(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;");
if (!invokeMethodId) {
qCWarning(QT_BT_ANDROID) << "Could not invoke method.";
return false;
}
jmethodID valueOfMethodId = env->GetStaticMethodID(integerClass, "valueOf", "(I)Ljava/lang/Integer;");
jclass objectClass = env->FindClass("java/lang/Object");
jobjectArray invokeParams = env->NewObjectArray(1, objectClass, env->CallStaticObjectMethod(integerClass, valueOfMethodId, channel));
jobject invokeResult = env->CallObjectMethod(method.object(), invokeMethodId,
remoteDevice.object(), invokeParams);
if (!invokeResult)
{
qCWarning(QT_BT_ANDROID) << "Invoke Resulted with error.";
if (env->ExceptionCheck()) {
env->ExceptionDescribe();
env->ExceptionClear();
}
return false;
}
socketObject = QAndroidJniObject(invokeResult);
socketObject.callMethod<void>("connect");
if (env->ExceptionCheck()) {
env->ExceptionDescribe();
env->ExceptionClear();
//.........这里部分代码省略.........