Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-34716

CLONE - QDesktopServices::openUrl didn't return any code.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • P2: Important
    • 5.2.0 RC1, 5.3.2
    • 5.3.0
    • QPA
    • None
    • Android
    • 4946ed049608251cf750a6250b4c94cda1c2e707

    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

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            stromme Christian
            escor Stefan Oswald
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes