I understand how to call Javascript from my WebView, that isn’t the issue.
if(javascriptCall!=null){
String hardCodedexample = "1959602";
webView.loadUrl("http://myappexample+ username);
webView.loadUrl("javascript:" + "window.application.relocateTo({location:'patients/details',params:{EMPIID:"+ hardCodedEMPIID +"}})");
}
javascriptCall is a String which is passed to my webview activity. hardCodedEMPIID is just an example for our testing. My problem is that when I allow the app the run normally on the device my javascript method doesn’t seem to work. It loads the myappexample and I can’t tell what happened with my javascript call.
When I debug the app and single step through the code it properly calls the method. I’m confused on how this is possible? the different between single step and normal execution.
You should wait for
onPageFinished(WebView view, String url)event called byWebViewClient(http://developer.android.com/reference/android/webkit/WebViewClient.html#onPageFinished(android.webkit.WebView, java.lang.String) ) . JavaScript file with your function might not be loaded right away after callingloadUrl.