Answer the question
In order to leave comments, you need to log in
How to make a bridge between JavaScript inside a WebView and Java for an android application?
I want to try
to make a program based on this video: https://www.youtube.com/watch?v=uVqp1zcMfbE
system commands (known as system() in C/C++). From the Java side, there should be no problem in using one or the other. A couple of imports, a couple of lines... But how to make a "bridge"? If possible
Answer the question
In order to leave comments, you need to log in
Look at this WebView method . It allows you to call an embedded Java object inside a page via Javascript.
If you're too lazy to follow the link:
class JsObject {
@JavascriptInterface
public String toString() { return "injectedObject"; }
}
webView.addJavascriptInterface(new JsObject(), "injectedObject");
webView.loadData("", "text/html", null);
webView.loadUrl("javascript:alert(injectedObject.toString())");
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question