Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Throwing exception when i open android webview in qt 5.2 using android extras

Throwing exception when i open android webview in qt 5.2 using android extras

Scheduled Pinned Locked Moved Mobile and Embedded
3 Posts 2 Posters 1.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kranthi
    wrote on 27 Feb 2014, 10:47 last edited by
    #1

    Hi,
    I am getting the following Throwable Exception when I try to display android Webview using setContentView() of android in Qt Application.

    W/webview_proxy( 9549): java.lang.Throwable: Warning: A WebView method was called on thread 'Thread-845'. All WebView methods must be called on the UI thread. Future versions of WebView may not support use on other threads.
    W/webview_proxy( 9549): at android.webkit.WebView.checkThread(WebView.java:1895)
    W/webview_proxy( 9549): at android.webkit.WebView.ensureProviderCreated(WebView.java:1878)
    W/webview_proxy( 9549): at android.webkit.WebView.setOverScrollMode(WebView.java:1935)
    W/webview_proxy( 9549): at android.view.View.<init>(View.java:3346)
    W/webview_proxy( 9549): at android.view.View.<init>(View.java:3422)
    W/webview_proxy( 9549): at android.view.ViewGroup.<init>(ViewGroup.java:432)
    W/webview_proxy( 9549): at android.widget.AbsoluteLayout.<init>(AbsoluteLayout.java:52)
    W/webview_proxy( 9549): at android.webkit.WebView.<init>(WebView.java:505)
    W/webview_proxy( 9549): at android.webkit.WebView.<init>(WebView.java:482)
    W/webview_proxy( 9549): at android.webkit.WebView.<init>(Web

    Why this is happening, Please provide the solution.

    Thanks
    Kranthi Talluri

    1 Reply Last reply
    0
    • G Offline
      G Offline
      Gianluca
      wrote on 27 Feb 2014, 11:37 last edited by
      #2

      The error message indicates also the solution:

      "All WebView methods must be called on the UI thread."

      So, you must execute the method on the UI thread. For doing so, the Android API provides the runOnUIThread method:
      http://developer.android.com/reference/android/app/Activity.html#runOnUiThread(java.lang.Runnable)

      1 Reply Last reply
      0
      • K Offline
        K Offline
        kranthi
        wrote on 27 Feb 2014, 13:26 last edited by
        #3

        I written the code as follows even then it is throwing same Exception:

        public void invokeview(){

         final Activity activity=this;
        
                 webView = new WebView(this);
                 new Thread() {
                            public void run() {
        
                                    try {
                                        activity.runOnUiThread(new Runnable() {
        
                                            @Override
                                            public void run() {
                                            webView.getSettings().setJavaScriptEnabled(true);
                                            webView.loadUrl("http://www.google.com");
                                             setContentView(webView);
                                            }
                                        });
        
                                    } catch (Exception e) {
                                        e.printStackTrace();
        
                                }
                            }
                        }.start();
        }
        
        1 Reply Last reply
        0

        1/3

        27 Feb 2014, 10:47

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved