我在将保存的数据从 Android 应用程序插入 html 输入时遇到问题。站点已加载到 WebView 组件中,因此我可以在我的应用程序中访问我的站点,但我仍然无法将保存的数据(来自以前的活动)插入到 html 文本输入中......我找到了一些代码 -webview.loadUrl("javascript:document.getElementById('pass_id').value = 'y2Yb2q2ckM'");
并尝试使用来自此链接 - https://stackoverflow.com/a/12450427/1196540但这些代码对我不起作用......有人可以提供建议或帮助我解决我的问题吗?
UPD ,这是我的网络表单:
<form method="post" action="">
<input name="pass" id="pass_id" type="password" autocomplete="off" value="" class="keyboardInput" onkeyup="$('#warn2').show();"/>
更新 2
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_browser_screen);
Intent intent = getIntent();
CLIENT_ID = intent.getExtras().getString("CLIENT_ID");
lang = intent.getExtras().getString("LANGUAGE");
CLIENT_PWD = intent.getExtras().getString("PASSWORD");
if (lang.equals("English"))
url = link.getEng();
else if (lang.equals("Russian"))
url = link.getRussian();
else if (lang.equals("Dutch(German)"))
url = link.getDeutch();
else if (lang.equals("French"))
url = link.getFrance();
else if (lang.equals("Italian"))
url = link.getItalian();
else if (lang.equals("Spanish"))
url = link.getSpanish();
//go to the website
WebView webview = new WebView(this);
setContentView(webview);
WebSettings webSettings = webview.getSettings();
webSettings.setJavaScriptEnabled(true);
webview.setWebViewClient(new WebViewClient());
data = "client_id=" + CLIENT_ID;
webview.postUrl(url, EncodingUtils.getBytes(data, "base64"));
//insert pass
//webview.loadUrl("javascript:document.getElementById('pass_id').value = 'y2Yb2q2ckM'");
webview.loadUrl("javascript:document.getElementById('pass_id').focus()");
}