0
根据我的标题,我想在我的WebView
中检测到一个按钮上的点击并自动填充用户名密码字段。这是我有:检测按钮点击事件和在Android Web视图中填写表格
@Override
public void onPageFinished(final WebView view, String url) {
String user = "user";
String pwd = "password";
view.addJavascriptInterface(new Object() {
@JavascriptInterface
public void performClick() throws Exception {
Log.d("LOGIN::", "Clicked from on finished");
Toast.makeText(getApplicationContext(), "Login clicked", Toast.LENGTH_LONG).show();
String js = "javascript:document.getElementById('login')[0].value = '" + user+ "';document.getElementById('login')[1].value='" + pwd+ "';";
view.evaluateJavascript(js, new ValueCallback<String>() {
@Override
public void onReceiveValue(String s) {
Log.d("form filled javascript", s); // Prints the string 'null' NOT Java null
}
})
}
}, "fill");
我能够检测到按钮上的点击,但无法填写表格。
这正是我正在使用,结帐我的代码片段上面。 – user3291059