Details
Description
Thanks, now its fixed and there is a little bit more code to get the return code of QDesktopServices::openUrl working.
./qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
public static boolean openURL(String url) { try { Uri uri = Uri.parse(url); Intent intent = new Intent(Intent.ACTION_VIEW, uri); activity().startActivity(intent); } catch (Exception e) { e.printStackTrace(); return false; } return true; }
./qtbase/src/plugins/platforms/android/src/qandroidplatformservices.cpp
QAndroidPlatformServices::QAndroidPlatformServices() { QtAndroid::AttachedJNIEnv env; if (!env.jniEnv) return; m_openURIMethodID = env.jniEnv->GetStaticMethodID(QtAndroid::applicationClass(), "openURL", "(Ljava/lang/String;)Z"); } bool QAndroidPlatformServices::openUrl(const QUrl &url) { QtAndroid::AttachedJNIEnv env; bool result; if (!env.jniEnv) return false; jstring string = env.jniEnv->NewString(reinterpret_cast<const jchar *>(url.toString().constData()), url.toString().length()); result = env.jniEnv->CallStaticBooleanMethod(QtAndroid::applicationClass(), m_openURIMethodID, string); env.jniEnv->DeleteLocalRef(string); return result; }
Attachments
For Gerrit Dashboard: QTBUG-34716 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
91550,2 | Android: Fix QAndroidPlatformServices::openUrl(). | 5.3 | qt/qtbase | Status: MERGED | +2 | 0 |