I am viewing the text data sent in the server method in the Android web view.
How do I retrieve this data from the webview by textual data?I tried the code below, but the value is null.
public class MainActivity extensions AppCompatActivity{
private Timer mainTimer;
private MainTimerTask mainTimerTask;
private int count = 0;
private handler mHandler=newHandler();
private TextView the label;
//
private Timer mainTimer2;
private MainTimerTask mainTimerTask2;
private int count2 = 0;
private handler mHandler2 = newHandler();
@ Override
protected void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
WebView myWebView= (WebView) findViewById (R.id.webView);
myWebView.setWebViewClient(newWebViewClient());
myWebView.loadUrl("http://192.168.43.238/"; // http://192.168.43.238/
WebSettings webSettings=myWebView.getSettings();
webSettings.setDefaultFontSize(60);
myWebView.scrollTo(0, myWebView.getContentHeight());
count=myWebView.getContentHeight();
This.mainTimer=newTimer();
This.mainTimerTask = newMainTimerTask();
This.mainTimer.schedule(mainTimerTask, 1000, 100);
myWebView.evaluateJavascript(
"(function() {return( document.getElement.inertext);})();",
newValueCallback<String>(){
@ Override
public void onReceiveValue(Stringhtml){
Log.d("HTML", html);
// code here
}
});
}
public class MainTimerTask extensions TimerTask {
@ Override
public void run() {
mHandler.post(new Runnable(){
public void run() {
WebView myWebView= (WebView) findViewById (R.id.webView);
count+=1000;
myWebView.scrollTo(0, count); // getContentHeight();
WebSettings webSettings=myWebView.getSettings();
webSettings.setDefaultFontSize(60);
myWebView.evaluateJavascript(
"(function() {return( document.getElement.inertext);})();",
newValueCallback<String>(){
@ Override
public void onReceiveValue(Stringhtml){
Log.d("HTML", html);
// code here
}
});
}
});
}
}
}
document.getElement.innerText
does not appear to be working properly
When javascript retrieves a specific element, it is done like document.getElementById("id")
, so isn't it javascript("(function(){return(document.getElement.inertext);});" error?
I think it would be better to open the web page you are trying to open from the PC's Chrome and run javascript from the console to see if the results come back as expected.
↓Wouldn't it be better to refer to these things?
http://www.buildinsider.net/web/chromedevtools/01#page-9
916 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
618 Uncaught (inpromise) Error on Electron: An object could not be cloned
574 Who developed the "avformat-59.dll" that comes with FFmpeg?
613 GDB gets version error when attempting to debug with the Presense SDK (IDE)
© 2024 OneMinuteCode. All rights reserved.