I am looking to create a feature where users can input a vehicle number, retrieve the data, and display the vehicle details without using a webview. Currently, I have been successful in populating the data with the following code snippet:
webView = (WebView) findViewById(R.id.webView1);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("https://parivahan.gov.in/rcdlstatus/vahan/rcstatus.xhtml");
webView.setWebViewClient(new WebViewClient() {
public void onPageFinished(WebView view, String url) {
String reg1="KA51X";
String reg2="2442";
if(isFirstLoad) {
webView.loadUrl("javascript: {" +
"document.getElementById('convVeh_Form:tf_reg_no1').value = '" + reg1 + "';" +
"document.getElementById('convVeh_Form:tf_reg_no2').value = '" + reg2 + "';" +
"var frms = document.getElementsByName('convVeh_Form');" +
"frms[0].submit(); };");
isFirstLoad = false;
}
}
});
The website providing the data for this app can be accessed here:
Currently, I am attempting to trigger the submit button with the following lines of code:
"frms[0].submit(); };");
as well as,
"javascript:(function(){document.getElementById('convVeh_Form:j_idt21').click();})()"
However, these commands are not producing the desired results. How can I successfully click the button identified by the Id
convVeh_Form:j_idt21
Once the button is clicked, the response from the website will be received. Is there a way to extract and display this response text within the app's textview?