Created
January 17, 2017 17:09
-
-
Save wesleyduff/403fc3a24f5a0f4508ef0e5f55a95ae9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Java | |
webview.getSettings().setJavaScriptEnabled(true); | |
webview.loadUrl("<your html file>"); //not in scope of this gist | |
webview.setWebViewClient(new WebViewClient(){ | |
public void onPageFinished(WebView view, String url){ | |
//Here you want to use .loadUrl again | |
//on the webview object and pass in | |
//"javascript:<your javaScript function" | |
webview.loadUrl("javascript:myJavaScriptFunc('" + argumentPassingIn + "')"); //if passing in an object. Mapping may need to take place | |
} | |
}); | |
//HTML | |
<!DOCTYPE html> | |
<html> | |
<head><title>Demo</title></head> | |
<body> | |
<h1>Body</h1> | |
<script> | |
myJavaScriptFunc(val){ | |
//Do something with val | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment