本文整理汇总了C++中QAndroidJniEnvironment::GetObjectClass方法的典型用法代码示例。如果您正苦于以下问题:C++ QAndroidJniEnvironment::GetObjectClass方法的具体用法?C++ QAndroidJniEnvironment::GetObjectClass怎么用?C++ QAndroidJniEnvironment::GetObjectClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QAndroidJniEnvironment
的用法示例。
在下文中一共展示了QAndroidJniEnvironment::GetObjectClass方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: registerNativeMethods
bool JniNative::registerNativeMethods()
{
JNINativeMethod methods[] {
{"notifyMsg", "(III)V", (void*)notifyMsg},
{"setDirectBuffer","(Ljava/lang/Object;I)V",(void*)setDirectBuffer}
};
const char *classname = "an/qt/useJar/ExtendsQtNative";
jclass clazz;
QAndroidJniEnvironment env;
QAndroidJniObject javaClass(classname);
clazz = env->GetObjectClass(javaClass.object<jobject>());
// QDBG << "find ExtendsQtNative - " << clazz;
bool result = false;
if (clazz) {
jint ret = env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0]));
env->DeleteLocalRef(clazz);
// QDBG << "RegisterNatives return - " << ret;
result = ret >= 0;
}
if (env->ExceptionCheck())
env->ExceptionClear();
return result;
}
示例2: registerNativeMethods
static bool registerNativeMethods()
{
JNINativeMethod methods[] {
{"OnImageCaptured", "(ILjava/lang/String;)V", (void*)onImageCaptured}
};
const char *classname = "an/qt/imageProcessor/ImageCaptureNative";
jclass clazz;
QAndroidJniEnvironment env;
QAndroidJniObject javaClass(classname);
clazz = env->GetObjectClass(javaClass.object<jobject>());
//clazz = env->FindClass(classname);
qDebug() << "find ImageCaptureNative - " << clazz;
bool result = false;
if(clazz)
{
jint ret = env->RegisterNatives(clazz,
methods,
sizeof(methods) / sizeof(methods[0]));
env->DeleteLocalRef(clazz);
qDebug() << "RegisterNatives return - " << ret;
result = ret >= 0;
}
if(env->ExceptionCheck()) env->ExceptionClear();
return result;
}
示例3: 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);
}
示例4: aseman_android_loclis_registerNativeMethods
bool aseman_android_loclis_registerNativeMethods() {
JNINativeMethod methods[] {{"_locationListened", "(DDDLjava/lang/String;)V", reinterpret_cast<void *>(locationListened)}};
QAndroidJniObject javaClass("land/aseman/android/extra/AsemanLocationListener");
QAndroidJniEnvironment env;
jclass objectClass = env->GetObjectClass(javaClass.object<jobject>());
env->RegisterNatives(objectClass, methods, sizeof(methods) / sizeof(methods[0]));
env->DeleteLocalRef(objectClass);
return true;
}
示例5: retrieveDensity
float ScreenValues::retrieveDensity()
{
#ifdef Q_OS_ANDROID
QAndroidJniEnvironment env;
env->PushLocalFrame(9);
QAndroidJniObject activity = QAndroidJniObject::callStaticObjectMethod("org/qtproject/qt5/android/QtNative",
"activity",
"()Landroid/app/Activity;");
jclass activityClass = env->GetObjectClass(activity.object<jobject>());
jmethodID mIDGetResources = env->GetMethodID(activityClass,
"getResources",
"()Landroid/content/res/Resources;");
jobject resources = env->CallObjectMethod(activity.object<jobject>(), mIDGetResources);
jclass resourcesClass = env->GetObjectClass(resources);
jmethodID mIDGetDisplayMetrics = env->GetMethodID(resourcesClass,
"getDisplayMetrics",
"()Landroid/util/DisplayMetrics;");
jobject displayMetrics = env->CallObjectMethod(resources, mIDGetDisplayMetrics);
jclass displayMetricsClass = env->GetObjectClass(displayMetrics);
jfieldID fIDDensityDpi = env->GetFieldID(displayMetricsClass, "density", "F");
jfloat densityDpi = env->GetFloatField(displayMetrics, fIDDensityDpi);
float result = (float)densityDpi;
env->PopLocalFrame(NULL);
return result;
#else
return QGuiApplication::primaryScreen()->physicalDotsPerInch();
#endif
}
示例6: 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();
//.........这里部分代码省略.........