I use Android Studio to set up WebView in Java to display any HTML.
Therefore, I would like to interconnect Android with JavaScript in HTML.
First, for JavaScript→ Android (Java), I succeeded in calling any Java method on Android using @JavascriptInterface
.Arguments and so on have crossed correctly.
On the other hand, I'm stuck because I don't know how to call any method in HTML from Android (Java).
There were some information that I could call in webview.loadUrl("javascript:hoge();");
but it doesn't show up even if I install an alert, so I think it's not called well.
webview.validateJavascript("hoge();", null);
did the same.
I apologize for the inconvenience, but I would appreciate it if you could let me know.
javascript java android webview
When you ask questions, be sure to write down the environmental information first as a minimum of manners.
For Android development, the OS version and vendor of the device, IDE (Android Studio) version, Android SDK version, targetSdkVersion value, etc.
In order to use Note that JS can only be run after the page loading is complete.alert()
on the JS side, the WebView.setWebChromeClient()
must have a WebChrome instance.
Please refer to the following for details.
© 2024 OneMinuteCode. All rights reserved.