Android: A WebView method was called on thread ‘JavaBridge’.

Posted: December 4, 2014 in Android

All WebView methods must be called on the same thread.

Javascript interface callbacks are performed in a background thread, so to call WebView method, we need post it to the UI thread.

webView.post(new Runnable() {
     @Override
     public void run() {
         webView.loadUrl(urlToLoad);
     }
});
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s