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

QtWebView on Android does not handle geo:, mailto: and other scheme urls

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.6.2, 5.7.1
    • 5.5.1
    • WebView
    • None
    • Ib569ec1598f76f823b2293446ea4e513764ef1fa

    Description

      I tried to open geo: link (to launch navigation software from webapp) in Android WebView, and it failed with ERR_UNKNOWN_URL_SCHEME error.

      Looks like scheme handling must be implemented explicitly. Here's QtAndroidWebViewClient extra method is needed to make it work:

              @Override
              public boolean shouldOverrideUrlLoading(WebView view, String url) 
              {
                  // handle http: and http: as usual
                  if(URLUtil.isNetworkUrl(url))
                      return false;
      
                  // try to handle geo:, tel:, mailto: and other schemes
                  try {
                      Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
                      view.getContext().startActivity(intent);
                      return true;
                  } catch (Exception e) {
                      e.printStackTrace();
                      return false;
                  }
              }
      

      It starts to suggest GPS navigation app, email app and so forth, while passing "invalid:" scheme gives same "ERR_UNKNOWN_URL_SCHEME" error.

      I'll try to send it to codereview, if maintainers are not against, when I find free time.

      iOS webview handles mailto, tel, sms schemes by default (though geo: has to be changed into maps://).

      Attachments

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

        Activity

          People

            talkless Vincas Dargis
            talkless Vincas Dargis
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes