I'm developing an Android App and I have a piece of javascript code that is being loaded from "str8red.com" within a webview:
<script>var name = "bob", age = 30;</script>
There's a textbox in the app that I can set using:
textView.setText("Static Text")
I want to populate my textbox with the value of the name
variable from the javascript. I've tried using
webview.loadUrl("javascript:Android.getIds(Ids);");
and evaluateJavascript
without any luck. I've also searched through various guides on stack overflow and other websites but couldn't find a solution.
Below is the code snippet for loading the webview:
wv = (WebView) findViewById(R.id.wv);
//Enable JavaScript
wv.getSettings().setJavaScriptEnabled(true);
wv.setFocusable(true);
wv.setFocusableInTouchMode(true);
//Set Render Priority To High
wv.getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH);
wv.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
wv.getSettings().setDomStorageEnabled(true);
wv.getSettings().setDatabaseEnabled(true);
wv.getSettings().setAppCacheEnabled(true);
wv.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
//Load Url
wv.loadUrl("https://str8red.com/");