本文整理汇总了C++中QAndroidJniEnvironment::ExceptionClear方法的典型用法代码示例。如果您正苦于以下问题:C++ QAndroidJniEnvironment::ExceptionClear方法的具体用法?C++ QAndroidJniEnvironment::ExceptionClear怎么用?C++ QAndroidJniEnvironment::ExceptionClear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QAndroidJniEnvironment
的用法示例。
在下文中一共展示了QAndroidJniEnvironment::ExceptionClear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: writeToPort
qint64 QSerialPortPrivate::writeToPort(const char *data, qint64 maxSize)
{
if (deviceId == BAD_PORT)
{
q_ptr->setError(QSerialPort::NotOpenError);
return 0;
}
QAndroidJniEnvironment jniEnv;
jbyteArray jarrayL = jniEnv->NewByteArray(maxSize);
jniEnv->SetByteArrayRegion(jarrayL, 0, maxSize, (jbyte *)data);
if (jniEnv->ExceptionCheck())
jniEnv->ExceptionClear();
int resultL = QAndroidJniObject::callStaticMethod<jint>(
kJniClassName,
"write",
"(I[BI)I",
deviceId,
jarrayL,
internalWriteTimeoutMsec);
if (jniEnv->ExceptionCheck())
{
jniEnv->ExceptionClear();
q_ptr->setErrorString(QStringLiteral("Writing to the device threw an exception"));
jniEnv->DeleteLocalRef(jarrayL);
return 0;
}
jniEnv->DeleteLocalRef(jarrayL);
return resultL;
}
示例2: AndroidBroadcastReceiver
LocalDeviceBroadcastReceiver::LocalDeviceBroadcastReceiver(QObject *parent) :
AndroidBroadcastReceiver(parent), previousScanMode(0)
{
addAction(valueForStaticField(JavaNames::BluetoothDevice, JavaNames::ActionBondStateChanged));
addAction(valueForStaticField(JavaNames::BluetoothAdapter, JavaNames::ActionScanModeChanged));
addAction(valueForStaticField(JavaNames::BluetoothDevice, JavaNames::ActionAclConnected));
addAction(valueForStaticField(JavaNames::BluetoothDevice, JavaNames::ActionAclDisconnected));
if (QtAndroidPrivate::androidSdkVersion() >= 15)
addAction(valueForStaticField(JavaNames::BluetoothDevice, JavaNames::ActionPairingRequest)); //API 15
//cache integer values for host & bonding mode
//don't use the java fields directly but refer to them by name
QAndroidJniEnvironment env;
for (uint i = 0; i < (sizeof(hostModePreset)/sizeof(hostModePreset[0])); i++) {
hostModePreset[i] = QAndroidJniObject::getStaticField<jint>(
"android/bluetooth/BluetoothAdapter",
scanModes[i]);
if (env->ExceptionCheck()) {
env->ExceptionDescribe();
env->ExceptionClear();
hostModePreset[i] = 0;
}
}
for (uint i = 0; i < (sizeof(bondingModePreset)/sizeof(bondingModePreset[0])); i++) {
bondingModePreset[i] = QAndroidJniObject::getStaticField<jint>(
"android/bluetooth/BluetoothDevice",
bondModes[i]);
if (env->ExceptionCheck()) {
env->ExceptionDescribe();
env->ExceptionClear();
bondingModePreset[i] = 0;
}
}
}
示例3: setSocketDescriptor
bool QBluetoothSocketPrivate::setSocketDescriptor(const QAndroidJniObject &socket, QBluetoothServiceInfo::Protocol socketType_,
QBluetoothSocket::SocketState socketState, QBluetoothSocket::OpenMode openMode)
{
Q_Q(QBluetoothSocket);
if (q->state() != QBluetoothSocket::UnconnectedState || !socket.isValid())
return false;
if (!ensureNativeSocket(socketType_))
return false;
socketObject = socket;
QAndroidJniEnvironment env;
inputStream = socketObject.callObjectMethod("getInputStream", "()Ljava/io/InputStream;");
outputStream = socketObject.callObjectMethod("getOutputStream", "()Ljava/io/OutputStream;");
if (env->ExceptionCheck() || !inputStream.isValid() || !outputStream.isValid()) {
env->ExceptionDescribe();
env->ExceptionClear();
//close socket again
socketObject.callMethod<void>("close");
if (env->ExceptionCheck()) {
env->ExceptionDescribe();
env->ExceptionClear();
}
socketObject = inputStream = outputStream = remoteDevice = QAndroidJniObject();
errorString = QBluetoothSocket::tr("Obtaining streams for service failed");
q->setSocketError(QBluetoothSocket::NetworkError);
q->setSocketState(QBluetoothSocket::UnconnectedState);
return false;
}
remoteDevice = socketObject.callObjectMethod("getRemoteDevice", "()Landroid/bluetooth/BluetoothDevice;");
if (inputThread) {
inputThread->deleteLater();
inputThread = 0;
}
inputThread = new InputStreamThread(this);
QObject::connect(inputThread, SIGNAL(dataAvailable()),
q, SIGNAL(readyRead()), Qt::QueuedConnection);
QObject::connect(inputThread, SIGNAL(error(int)),
this, SLOT(inputThreadError(int)), Qt::QueuedConnection);
inputThread->run();
q->setSocketState(socketState);
q->setOpenMode(openMode | QIODevice::Unbuffered);
if (openMode == QBluetoothSocket::ConnectedState)
emit q->connected();
return true;
}
示例4: registerNatives
void QASystemDispatcher::registerNatives()
{
#ifdef Q_OS_ANDROID
QAndroidJniEnvironment env;
jclass clazz = env->FindClass(JCLASS_Name);
if (!clazz)
{
qCritical() << QString("Can't find %1 class").arg(QString(JCLASS_Name));
return ;
}
JNINativeMethod methods[] =
{
{"jniEmit", EMIT_SIGNATURE, (void *)&jniEmit},
};
int numMethods = sizeof(methods) / sizeof(methods[0]);
if (env->RegisterNatives(clazz, methods, numMethods) < 0) {
if (env->ExceptionOccurred()) {
env->ExceptionDescribe();
env->ExceptionClear();
qCritical() << "Exception occurred!!!";
return;
}
}
#endif
}
示例5: 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;
}
示例6: 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;
}
示例7: readDescriptor
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);
}
示例8: getDownloadPath
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;
}
示例9: readCharacteristic
void QLowEnergyControllerPrivate::readCharacteristic(
const QSharedPointer<QLowEnergyServicePrivate> service,
const QLowEnergyHandle charHandle)
{
Q_ASSERT(!service.isNull());
if (!service->characteristicList.contains(charHandle))
return;
QAndroidJniEnvironment env;
bool result = false;
if (hub) {
qCDebug(QT_BT_ANDROID) << "Read characteristic with handle"
<< charHandle << service->uuid;
result = hub->javaObject().callMethod<jboolean>("readCharacteristic",
"(I)Z", charHandle);
}
if (env->ExceptionOccurred()) {
env->ExceptionDescribe();
env->ExceptionClear();
result = false;
}
if (!result)
service->setError(QLowEnergyService::CharacteristicReadError);
}
示例10: inputThreadError
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();
}
示例11: writeDescriptor
void QLowEnergyControllerPrivate::writeDescriptor(
const QSharedPointer<QLowEnergyServicePrivate> service,
const QLowEnergyHandle /*charHandle*/,
const QLowEnergyHandle descHandle,
const QByteArray &newValue)
{
Q_ASSERT(!service.isNull());
QAndroidJniEnvironment env;
jbyteArray payload;
payload = env->NewByteArray(newValue.size());
env->SetByteArrayRegion(payload, 0, newValue.size(),
(jbyte *)newValue.constData());
bool result = false;
if (hub) {
qCDebug(QT_BT_ANDROID) << "Write descriptor with handle " << descHandle
<< newValue.toHex() << "(service:" << service->uuid << ")";
result = hub->javaObject().callMethod<jboolean>("writeDescriptor", "(I[B)Z",
descHandle, payload);
}
if (env->ExceptionOccurred()) {
env->ExceptionDescribe();
env->ExceptionClear();
result = false;
}
env->DeleteLocalRef(payload);
if (!result)
service->setError(QLowEnergyService::DescriptorWriteError);
}
示例12: writeData
qint64 QBluetoothSocketPrivate::writeData(const char *data, qint64 maxSize)
{
//TODO implement buffered behavior (so far only unbuffered)
Q_Q(QBluetoothSocket);
if (state != QBluetoothSocket::ConnectedState || !outputStream.isValid()) {
qCWarning(QT_BT_ANDROID) << "Socket::writeData: " << state << outputStream.isValid();
errorString = QBluetoothSocket::tr("Cannot write while not connected");
q->setSocketError(QBluetoothSocket::OperationError);
return -1;
}
QAndroidJniEnvironment env;
jbyteArray nativeData = env->NewByteArray((qint32)maxSize);
env->SetByteArrayRegion(nativeData, 0, (qint32)maxSize, reinterpret_cast<const jbyte*>(data));
outputStream.callMethod<void>("write", "([BII)V", nativeData, 0, (qint32)maxSize);
env->DeleteLocalRef(nativeData);
emit q->bytesWritten(maxSize);
if (env->ExceptionCheck()) {
qCWarning(QT_BT_ANDROID) << "Error while writing";
env->ExceptionDescribe();
env->ExceptionClear();
errorString = QBluetoothSocket::tr("Error during write on socket.");
q->setSocketError(QBluetoothSocket::NetworkError);
return -1;
}
return maxSize;
}
示例13: 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
}
示例14: createAlbumPath
QString Wpp::createAlbumPath(const QString& albumName)
{
QString parentPath;
#if defined(Q_OS_ANDROID)
QAndroidJniObject Environment__MEDIA_MOUNTED = QAndroidJniObject::getStaticObjectField(
"android/os/Environment", "MEDIA_MOUNTED", "Ljava/lang/String;");
qDebug() << "Environment__MEDIA_MOUNTED:isValid:" << Environment__MEDIA_MOUNTED.isValid() << ":toString:" << Environment__MEDIA_MOUNTED.toString();
QString Environment__MEDIA_MOUNTED_STRING = Environment__MEDIA_MOUNTED.toString();
QAndroidJniObject mediaState = QAndroidJniObject::callStaticObjectMethod("android/os/Environment", "getExternalStorageState", "()Ljava/lang/String;");
QString mediaStateString = mediaState.toString();
qDebug() <<"mediaStateString:"<< mediaStateString;
if(mediaStateString != Environment__MEDIA_MOUNTED_STRING )
{
qDebug() << "No SD Card...";
return QString();
}
//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;" );
parentPath = mediaPath.toString();
QAndroidJniEnvironment env;
if (env->ExceptionCheck()) {
// Handle exception here.
qDebug() << "[ERR]:Android(Extras):getting SD card path";
env->ExceptionClear();
}
#elif defined(Q_OS_IOS)
QStringList paths = QStandardPaths::standardLocations(QStandardPaths::DataLocation);
qDebug() << "[IOS]album parent paths count:" << paths.size();
parentPath = paths.first();
#else
QStringList paths = QStandardPaths::standardLocations(QStandardPaths::DataLocation);
qDebug() << "[Other OS]album parent paths count:" << paths.size();
parentPath = paths.first();
#endif
QDir dir(parentPath);
qDebug() << __FUNCTION__ << ":dir=" << dir.dirName();
QString userAlbumPath = parentPath.append("/").append(albumName);;
QDir userAlbumDir = userAlbumPath;
if( !userAlbumDir.exists() )
{
qDebug() << albumName << ":not exists, create it";
dir.mkpath( albumName );
}
else
{
qDebug() << albumName << ":exists";
}
return userAlbumPath;
}
示例15: cleanJavaException
void cleanJavaException()
{
QAndroidJniEnvironment env;
if (env->ExceptionCheck()) {
env->ExceptionDescribe();
env->ExceptionClear();
}
}