本文整理汇总了C++中QAndroidJniEnvironment::ReleaseStringUTFChars方法的典型用法代码示例。如果您正苦于以下问题:C++ QAndroidJniEnvironment::ReleaseStringUTFChars方法的具体用法?C++ QAndroidJniEnvironment::ReleaseStringUTFChars怎么用?C++ QAndroidJniEnvironment::ReleaseStringUTFChars使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QAndroidJniEnvironment
的用法示例。
在下文中一共展示了QAndroidJniEnvironment::ReleaseStringUTFChars方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: availablePortsByFiltersOfDevices
QList<QSerialPortInfo> availablePortsByFiltersOfDevices(bool &ok)
{
QList<QSerialPortInfo> serialPortInfoList;
//__android_log_print(ANDROID_LOG_INFO, V_TAG, "Collecting device list");
QAndroidJniObject resultL = QAndroidJniObject::callStaticObjectMethod(
V_jniClassName,
"availableDevicesInfo",
"()[Ljava/lang/String;");
if (!resultL.isValid()) {
__android_log_print(ANDROID_LOG_ERROR, V_TAG, "Error from availableDevicesInfo");
ok = false;
return serialPortInfoList;
}
QAndroidJniEnvironment envL;
jobjectArray objArrayL = resultL.object<jobjectArray>();
int countL = envL->GetArrayLength(objArrayL);
for (int iL = 0; iL < countL; iL++)
{
QSerialPortInfoPrivate priv;
jstring stringL = (jstring)(envL->GetObjectArrayElement(objArrayL, iL));
const char *rawStringL = envL->GetStringUTFChars(stringL, 0);
//__android_log_print(ANDROID_LOG_INFO, V_TAG, "Adding device: %s", rawStringL);
QStringList strListL = QString::fromUtf8(rawStringL).split(QStringLiteral(":"));
envL->ReleaseStringUTFChars(stringL, rawStringL);
priv.portName = strListL[0];
priv.device = strListL[0];
priv.manufacturer = strListL[1];
priv.productIdentifier = strListL[2].toInt();
priv.hasProductIdentifier = (priv.productIdentifier != 0) ? true: false;
priv.vendorIdentifier = strListL[3].toInt();
priv.hasVendorIdentifier = (priv.vendorIdentifier != 0) ? true: false;
serialPortInfoList.append(priv);
}
return serialPortInfoList;
}
示例2: handleActivityResult
void ImagePicker::handleActivityResult(int receiverRequestCode, int resultCode, const QAndroidJniObject & data)
{
qDebug() << __FUNCTION__;
int PICK_FROM_FILE = 2;
int PICK_FROM_FILE_KITKAT = 3;
jint Activity__RESULT_OK = QAndroidJniObject::getStaticField<jint>(
"android/app/Activity", "RESULT_OK");
qDebug() << __FUNCTION__ <<":receiverRequestCode=" << receiverRequestCode
<< ",resultCode=" << resultCode
<< ",Activity__RESULT_OK=" << Activity__RESULT_OK;
if ( ( receiverRequestCode == PICK_FROM_FILE || receiverRequestCode == PICK_FROM_FILE_KITKAT
|| receiverRequestCode == 200
|| receiverRequestCode == 9000 )
&& resultCode == Activity__RESULT_OK )
{
if ( receiverRequestCode == 200 )
{
QAndroidJniEnvironment env;
QAndroidJniObject pathsJavaObj = data.callObjectMethod("getStringArrayExtra","(Ljava/lang/String;)[Ljava/lang/String;");
qDebug() << __FUNCTION__ << "pathsJavaObj.isValid()=" << pathsJavaObj.isValid();
jobjectArray pathArray = pathsJavaObj.object<jobjectArray>();
int stringCount = env->GetArrayLength(pathArray);
QStringList paths;
for (int i=0; i<stringCount; i++)
{
jstring string = (jstring) env->GetObjectArrayElement(pathArray, i);
const char *rawString = env->GetStringUTFChars(string, 0);
// Don't forget to call `ReleaseStringUTFChars` when you're done.
QString path(rawString);
qDebug() << "path[]=" << path;
paths.append(path);
env->ReleaseStringUTFChars(string, rawString);
}
emit this->accepted(paths);
}
else if ( receiverRequestCode == 9000 )//PhotoPicker
{
qDebug() << __FUNCTION__ << ":code=9000";
QAndroidJniEnvironment env;
QAndroidJniObject PhotoPickerActivity__KEY_SELECTED_PHOTOS
= QAndroidJniObject::getStaticObjectField(
"me/iwf/photopicker/PhotoPickerActivity", "KEY_SELECTED_PHOTOS", "Ljava/lang/String;");
qDebug() << "PhotoPickerActivity__KEY_SELECTED_PHOTOS.isValid()=" << PhotoPickerActivity__KEY_SELECTED_PHOTOS.isValid();
QAndroidJniObject photos = data.callObjectMethod("getStringArrayListExtra","(Ljava/lang/String;)Ljava/util/ArrayList;",
PhotoPickerActivity__KEY_SELECTED_PHOTOS.object<jstring>());
qDebug() << "photos.isValid()=" << photos.isValid();
QAndroidJniObject photosObjectArray = photos.callObjectMethod("toArray","()[Ljava/lang/Object;");
qDebug() << "photosObjectArray.isValid()=" << photosObjectArray.isValid();
jobjectArray pathArray = photosObjectArray.object<jobjectArray>();
int stringCount = env->GetArrayLength(pathArray);
qDebug() << "pathArray=" << (void*)pathArray;
qDebug() << "stringCount=" << stringCount;
QStringList paths;
for (int i=0; i<stringCount; i++)
{
qDebug() << "for pathArray...i=" << i;
jstring string = (jstring) env->GetObjectArrayElement(pathArray, i);
const char *rawString = env->GetStringUTFChars(string, 0);
// Don't forget to call `ReleaseStringUTFChars` when you're done.
qDebug() << "for pathArray...i=" << i << ":rawString=" << rawString;
QString path(rawString);
qDebug() << "path[]=" << path;
paths.append(path);
env->ReleaseStringUTFChars(string, rawString);
}
emit this->accepted(paths);
}
else
{
QAndroidJniEnvironment env;
QAndroidJniObject uri = data.callObjectMethod("getData","()Landroid/net/Uri;");
qDebug() << __FUNCTION__ << "uri.isValid()=" << uri.isValid();
qDebug() << __FUNCTION__ << "uri=" << uri.toString();
/*
url is like: "content://media/external/images/media/87332"
for KitKat(android 4.4), uri is like: "content://com.android.providers.media.documents/document/image:3951"
*/
QAndroidJniObject activity = QtAndroid::androidActivity();
qDebug() << __FUNCTION__ << "activity.isValid()=" << activity.isValid();
QAndroidJniObject contentResolver = activity.callObjectMethod("getContentResolver","()Landroid/content/ContentResolver;");
qDebug() << __FUNCTION__ << "contentResolver.isValid()=" << contentResolver.isValid();
/*if ( receiverRequestCode == PICK_FROM_FILE_KITKAT )
{
//.........这里部分代码省略.........