Skip to content

Use evaluateJavascript instead of loadUrl("javascript:...") in WebApp interfaces#532

Open
jim-daf wants to merge 1 commit into
apps4av:masterfrom
jim-daf:fix-evaluatejavascript-handlers
Open

Use evaluateJavascript instead of loadUrl("javascript:...") in WebApp interfaces#532
jim-daf wants to merge 1 commit into
apps4av:masterfrom
jim-daf:fix-evaluatejavascript-handlers

Conversation

@jim-daf
Copy link
Copy Markdown

@jim-daf jim-daf commented May 16, 2026

Closes #531.

What changes

Across the three webinfc bridge classes, every mWebView.loadUrl("javascript:...") is replaced with mWebView.evaluateJavascript(script, null) and the "javascript:" prefix is stripped from the JS snippet strings.

Files touched:

  • app/src/main/java/com/ds/avare/webinfc/WebAppAircraftInterface.java
  • app/src/main/java/com/ds/avare/webinfc/WebAppMapInterface.java
  • app/src/main/java/com/ds/avare/webinfc/WebAppPlanInterface.java

26 call sites in total. Sample:

 else if(MSG_CLEAR_LIST == msg.what) {
-    mWebView.loadUrl("javascript:list_clear()");
+    mWebView.evaluateJavascript("list_clear()", null);
 }
 else if(MSG_ADD_LIST == msg.what) {
-    String func = "javascript:list_add(" + (String)msg.obj + ")";
-    mWebView.loadUrl(func);
+    String func = "list_add(" + (String)msg.obj + ")";
+    mWebView.evaluateJavascript(func, null);
 }

evaluateJavascript runs the JS without touching the WebView navigation stack, which is what every one of these helpers actually wants. The visible behaviour stays the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Webinfc bridge classes push JS via legacy loadUrl("javascript:...") instead of evaluateJavascript

1 participant