I have a user interface partially based on the Web (WebView). It is connected to the Android UI through the Javascript Interface . When you click on an element in a WebView, javascript calls before Android and Android receive a call in javascript / web stream. Not a UI thread (main).
It arrives on Android in 1 or less milliseconds. No problems. However, since I want to change the user interface, I need to switch to the user interface thread. (Android throws an exception if you change the user interface from the main thread). I am currently using a handler in the user interface thread and calling post () .
This code (Runnable) is then called somewhere between 120 and 300 ms later. This is a very noticeable lag in changing the user interface from the user touch.
Is there a way to speed up some code in a user interface thread? Here is a sample code:
Interface Class:
public class JSInterface { public void test() {
Added to web view as follows:
webview.addJavascriptInterface(new JSInterface(), "AndroidInterface");
Called in javascript as follows:
AndroidInterface.test();
Thanks!
cottonBallPaws
source share