web.html
<script>
function callbackFunctionName() {
$('input[name=keyword]').focus();
}
$(function() {
location.href = 'iwtapplink-command://initFocusWithSoftKeyboard?callback=callbackFunctionName';
});
</script>
android app
public boolean shouldOverrideUrlLoading(WebView paramWebView, String paramString) {
if (paramString.startsWith(activity.getString(R.string.appLinkIwtCommandInitFocusWithSoftKeyboard))) {
InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED,0);
String callback = "callbackFunctionName";
if(paramString.indexOf("?") > 0) {
try {
Map<String, String> queryStringMap = StringUtil.queryStringToMap(paramString.replace(activity.getString(R.string.appLinkIwtCommandInitFocusWithSoftKeyboard) + "?", ""));
if (!TextUtils.isEmpty(queryStringMap.get("callback"))) {
callback = queryStringMap.get("callback");
}
} catch (UnsupportedEncodingException uee) {
}
}
webView.loadUrl("javascript:" + callback + "();");
return true;
}
return false;
}