Closed jeremycw closed 13 years ago
The UI can't be touched by anything other than the main thread so loadUrl can't be called directly from onMessage instead you must do this:
public void onMessage(String msg) { final String data = msg; appView.post(new Runnable() { public void run() { appView.loadUrl(buildJavaScriptData(EVENT_ON_MESSAGE, data)); } }); }
or else you will sometimes get CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views
Thanks. I will do this.
Fixed!
The UI can't be touched by anything other than the main thread so loadUrl can't be called directly from onMessage instead you must do this:
public void onMessage(String msg) { final String data = msg; appView.post(new Runnable() { public void run() { appView.loadUrl(buildJavaScriptData(EVENT_ON_MESSAGE, data)); } }); }
or else you will sometimes get CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views