I have all this code but I can not get JavaScript Interface to work with an html button to execute a function in java that starts an application with the intent method.
I'm using Webview chrome client, an index.html file located in / main / assets that contains the buttons, if anyone can help me, it's urgent thanks.
// Enabling JS
mWebView.getSettings().setJavaScriptEnabled(true);
myWebView.addJavascriptInterface(new JavaScriptInterface(this), "Android");
// Java and Javascript interfacing
mWebView.addJavascriptInterface(new JavascriptInterface(), "JsInterface");
// outside oncreate
public class JavaScriptInterface {
Context mContext;
/** Instantiate the interface and set the context */
JavaScriptInterface(Context c) {
mContext = c;
}
/** Show a toast from the web page */
public void FacebookIntentShare(Intent) {
Facebook Intent
}
}
<a href="#" onclick="FacebookIntentShare()">Iniciar Facebook</a>
<button type="button" onclick="FacebookIntentShare();">Iniciar
Facebook</button>
<script type="text/javascript">
function FacebookIntentShare(){
//return value to Android
codigo que llame a una funcion de java...
la funcion de java debe lanzar un intent send to
}
</script>